Assembla home | Assembla project page
 

Changeset 1029

Show
Ignore:
Timestamp:
07/26/08 08:12:06 (4 months ago)
Author:
swiss
Message:

Updated the regular expression that pulls the artist images from the Last.FM website when playing Last.FM radio stations.

Fixes #156.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/swisscenter/ext/lastfm/lastfm.php

    r978 r1029  
    247247        { 
    248248          // Find all images of the artist on the page using a regular expression. 
    249           if (preg_match_all('#<a[^>]*href="([^"]*images/[0-]*[^"]*)"[^<]*<img[^>]*src="([^"]*)"#i',$html,$matches) >0 ) 
     249          if (preg_match_all('#<img src="(.*/serve/.*)" />#Ui',$html,$matches) >0 ) 
    250250          { 
     251                dump($matches); 
    251252            for ($i=0; $i<count($matches[1]); $i++) 
    252253            { 
     
    255256                $pics[] = $matches[1][$i]; 
    256257              else 
    257                 $pics[] = $matches[2][$i]; 
     258              { 
     259                $url_components = explode('/',$matches[1][$i]); 
     260                $url_components[ count($url_components)-2] = '_'; 
     261                $pics[] = implode('/',$url_components); 
     262              } 
    258263            } 
    259264          }