Problems with modified copy of the lastFM Agent

Hi,



I tried to create a copy of the lastFM-Agent which can be integrated into the Personal Media Agents. I created a copy of the lastFM bundle and modified the source of the init.py file:



<br />
import lastfm, re<br />
<br />
GOOGLE_JSON = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=large&q=%s+site:last.fm+inurl:music'<br />
BING_JSON   = 'http://api.bing.net/json.aspx?AppId=879000C53DA17EA8DB4CD1B103C00243FD0EFEE8&Version=2.2&Query=%s+site:last.fm&Sources=web&Web.Count=8&JsonType=raw'<br />
<br />
def Start():<br />
  HTTP.CacheTime = CACHE_1WEEK<br />
  <br />
class LastFmAgentArtist(Agent.Artist):<br />
  name = 'Last.fm-Artist'<br />
  languages = [Locale.Language.English, Locale.Language.Korean]<br />
  primary_provider = False<br />
  contributes_to = ['com.plexapp.agents.none']<br />
  <br />
  def search(self, results, media, lang):<br />
    score = 100<br />
     <br />
    for r in lastfm.SearchArtists(String.StripDiacritics(media.artist))[0]:<br />
      id = r[0]<br />
      if id.find('+noredirect') == -1:<br />
        id = r[1]<br />
        id = String.Quote(id.encode('utf-8'))<br />
        Log('id: ' + id + '  name: '+ r[1] + '   score: ' + str(score) + '   thumb: ' + str(r[2]))<br />
        results.Append(MetadataSearchResult(id = id.replace('%2B','%20'), name  = r[1], thumb = r[2], lang  = lang, score = score))<br />
        score = score - 2<br />
    <br />
    # Finally, de-dupe the results.<br />
    toWhack = []<br />
    resultMap = {}<br />
    for result in results:<br />
      if not resultMap.has_key(result.id):<br />
        resultMap[result.id] = True<br />
      else:<br />
        toWhack.append(result)<br />
...<br />




The newly created agent appears in the correct section but unfortunately it collects only strange informations: regardless which album will be scanned I get only artistinfo about an band called "Sixpence none the richer". I took a look at the logs and I guess the problem is with the media.artists data:


<br />
2011-04-15 19:43:58,642 (-5f3cfac0) :  DEBUG (core) - Loading plug-in code<br />
2011-04-15 19:43:59,277 (-5f3cfac0) :  DEBUG (agentkit) - Creating new agent class called LastFmAgentArtist<br />
2011-04-15 19:43:59,277 (-5f3cfac0) :  DEBUG (agentkit) - Updating agent information: [{'media_types': ['Artist'], 'accepts_from': None, 'fallback_agent': None, 'contributes_to': ['com.plexapp.agents.none'], 'languages': ['en', 'ko'], 'primary_provider': False, 'prefs': False, 'name': 'Last.fm-Artist'}]<br />
2011-04-15 19:43:59,279 (-5f3cfac0) :  DEBUG (core) - Requesting http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X0FnZW50U2VydmljZTpVcGRhdGVJbmZv/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQo2CmRpY3QKbGlzdApkaWN0Cmxpc3QKbGlzdApsaXN0CjIKczMyCmNvbS5wbGV4YXBwLmFnZW50cy5sYXN0Zm0tYXJ0aXN0czEwCmlkZW50aWZpZXJyMQpzMTAKYWdlbnRfaW5mbzEKcjIKOApyMwpzMTEKbWVkaWFfdHlwZXNuczEyCmFjY2VwdHNfZnJvbW5zMTQKZmFsbGJhY2tfYWdlbnRyNApzMTQKY29udHJpYnV0ZXNfdG9yNQpzOQpsYW5ndWFnZXNiMHMxNgpwcmltYXJ5X3Byb3ZpZGVyYjBzNQpwcmVmc3MxNApMYXN0LmZtLUFydGlzdHM0Cm5hbWUxCnM2CkFydGlzdDEKczIzCmNvbS5wbGV4YXBwLmFnZW50cy5ub25lMgpzMgplbnMyCmtvcjAK<br />
2011-04-15 19:43:59,296 (-5f3cfac0) :  DEBUG (agentkit) - Creating new agent class called LastFmAlbumAgent<br />
2011-04-15 19:43:59,297 (-5f3cfac0) :  DEBUG (agentkit) - Updating agent information: [{'media_types': ['Artist'], 'accepts_from': None, 'fallback_agent': None, 'contributes_to': ['com.plexapp.agents.none'], 'languages': ['en', 'ko'], 'primary_provider': False, 'prefs': False, 'name': 'Last.fm-Artist'}, {'media_types': ['Album'], 'accepts_from': None, 'fallback_agent': 'com.plexapp.agents.allmusic', 'contributes_to': None, 'languages': ['en'], 'primary_provider': True, 'prefs': False, 'name': 'Last.fm'}]<br />
2011-04-15 19:43:59,299 (-5f3cfac0) :  DEBUG (core) - Requesting http://127.0.0.1:32400/:/plugins/com.plexapp.system/messaging/function/X0FnZW50U2VydmljZTpVcGRhdGVJbmZv/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQo5CmRpY3QKbGlzdApkaWN0Cmxpc3QKbGlzdApsaXN0CmRpY3QKbGlzdApsaXN0CjIKczMyCmNvbS5wbGV4YXBwLmFnZW50cy5sYXN0Zm0tYXJ0aXN0czEwCmlkZW50aWZpZXJyMQpzMTAKYWdlbnRfaW5mbzIKcjIKcjYKOApyMwpzMTEKbWVkaWFfdHlwZXNuczEyCmFjY2VwdHNfZnJvbW5zMTQKZmFsbGJhY2tfYWdlbnRyNApzMTQKY29udHJpYnV0ZXNfdG9yNQpzOQpsYW5ndWFnZXNiMHMxNgpwcmltYXJ5X3Byb3ZpZGVyYjBzNQpwcmVmc3MxNApMYXN0LmZtLUFydGlzdHM0Cm5hbWUxCnM2CkFydGlzdDEKczIzCmNvbS5wbGV4YXBwLmFnZW50cy5ub25lMgpzMgplbnMyCmtvOApyNwpzMTEKbWVkaWFfdHlwZXNuczEyCmFjY2VwdHNfZnJvbXMyNwpjb20ucGxleGFwcC5hZ2VudHMuYWxsbXVzaWNzMTQKZmFsbGJhY2tfYWdlbnRuczE0CmNvbnRyaWJ1dGVzX3RvcjgKczkKbGFuZ3VhZ2VzYjFzMTYKcHJpbWFyeV9wcm92aWRlcmIwczUKcHJlZnNzNwpMYXN0LmZtczQKbmFtZTEKczUKQWxidW0xCnMyCmVucjAK<br />
2011-04-15 19:43:59,315 (-5f3cfac0) :  DEBUG (core) - Running pre-flight checks<br />
2011-04-15 19:43:59,317 (-5f3cfac0) :  INFO (core) - Started plug-in<br />
2011-04-15 19:43:59,317 (-5f3cfac0) :  DEBUG (socketinterface) - Starting socket server<br />
2011-04-15 19:43:59,321 (-5f3cfac0) :  DEBUG (core) - Created a thread named 'start'<br />
2011-04-15 19:43:59,322 (-5f3cfac0) :  INFO (socketinterface) - Socket server started on port 50121<br />
2011-04-15 19:43:59,323 (-5f3cfac0) :  INFO (pipeinterface) - Entering run loop<br />
2011-04-15 19:43:59,326 (-5f3cfac0) :  DEBUG (core) - Handling request GET /:/prefixes<br />
2011-04-15 19:43:59,328 (-5f3cfac0) :  DEBUG (core) - Response: 200<br />
2011-04-15 19:43:59,337 (-4f9e9000) :  DEBUG (core) - Handling request GET /:/plugins/com.plexapp.agents.lastfm-artist/messaging/function/X0FnZW50S2l0OlNlYXJjaA__/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoyCmRpY3QKZGljdAo0CnMyCnhuczQKbGFuZ3M2CkFydGlzdHMxMAptZWRpYV90eXBlYjBzNgptYW51YWxyMQpzNgprd2FyZ3MzCnMzNQpjb20ucGxleGFwcC5hZ2VudHMubm9uZTovLzE%40bGFuZz14bnM0Cmd1aWRiMXM1CmZvcmNlczIzCmNvbS5wbGV4YXBwLmFnZW50cy5ub25lczEzCnByaW1hcnlfYWdlbnRyMAo_<br />
2011-04-15 19:43:59,338 (-4f9e9000) :  INFO (agentkit) - Searching for matches for {'guid': 'com.plexapp.agents.none://1?lang=xn', 'force': True, 'primary_agent': 'com.plexapp.agents.none'}<br />
2011-04-15 19:43:59,339 (-4f9e9000) :  DEBUG (accessor) - Creating a new read-only model access point for provider com.plexapp.agents.none in namespace 'metadata'<br />
2011-04-15 19:43:59,339 (-4f9e9000) :  DEBUG (classes) - Generating class for 'Album' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,340 (-4f9e9000) :  DEBUG (classes) - Generating class for 'Episode' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,340 (-4f9e9000) :  DEBUG (classes) - Generating class for 'TV_Show' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,341 (-4f9e9000) :  DEBUG (classes) - Generating class for 'Artist' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,342 (-4f9e9000) :  DEBUG (classes) - Generating class for 'Track' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,342 (-4f9e9000) :  DEBUG (classes) - Generating class for 'Movie' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,343 (-4f9e9000) :  DEBUG (classes) - Generating class for 'VideoClip' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,343 (-4f9e9000) :  DEBUG (classes) - Generating class for 'Person' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,344 (-4f9e9000) :  DEBUG (classes) - Generating class for 'Role' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,344 (-4f9e9000) :  DEBUG (classes) - Generating class for 'Season' model in namespace 'metadata' with access point 'com.plexapp.agents.none'<br />
2011-04-15 19:43:59,345 (-4f9e9000) :  DEBUG (model) - Loading model with GUID com.plexapp.agents.none://1?lang=xn<br />
2011-04-15 19:43:59,349 (-4f9e9000) :  DEBUG (model) - Deserializing from /Users/gkoeder/Library/Application Support/Plex Media Server/Metadata/Artists/c/233aadf8c9a61f5e6851ca59458dc69c6c68eee.bundle/Contents/com.plexapp.agents.none/Info.xml<br />
2011-04-15 19:43:59,363 (-4f9e9000) :  DEBUG (core) - Fetching http://ws.audioscrobbler.com/2.0/?method=artist.search&artist=None&page=0&api_key=d5310352469c2631e5976d0f4a599773 from the HTTP cache<br />
2011-04-15 19:43:59,380 (-4f9e9000) :  INFO (core) - id: Sixpence%20None%20the%20Richer  name: Sixpence None the Richer   score: 100   thumb: http://userserve-ak.last.fm/serve/252/565723.jpg<br />
2011-04-15 19:43:59,380 (-4f9e9000) :  INFO (core) - id: None%20More%20Black  name: None More Black   score: 98   thumb: http://userserve-ak.last.fm/serve/252/314341.jpg<br />
2011-04-15 19:43:59,381 (-4f9e9000) :  INFO (core) - id: 2nd%20II%20None  name: 2nd II None   score: 96   thumb: http://userserve-ak.last.fm/serve/252/17008511.jpg<br />
2011-04-15 19:43:59,381 (-4f9e9000) :  INFO (core) - id: And%20Then%20There%20Were%20None  name: And Then There Were None   score: 94   thumb: http://userserve-ak.last.fm/serve/252/50419569.jpg<br />
2011-04-15 19:43:59,381 (-4f9e9000) :  INFO (core) - id: Xe-NONE  name: Xe-NONE   score: 92   thumb: http://userserve-ak.last.fm/serve/252/53116047.jpg<br />
2011-04-15 19:43:59,382 (-4f9e9000) :  INFO (core) - id: none  name: none   score: 90   thumb: http://userserve-ak.last.fm/serve/252/10897657.jpg<br />
2011-04-15 19:43:59,382 (-4f9e9000) :  INFO (core) - id: Apologies%2C%20I%20Have%20None  name: Apologies, I Have None   score: 88   thumb: http://userserve-ak.last.fm/serve/252/42957457.jpg<br />
2011-04-15 19:43:59,383 (-4f9e9000) :  INFO (core) - id: And%20None%20of%20Them%20Knew%20They%20Were%20Robots  name: And None of Them Knew They Were Robots   score: 86   thumb: http://userserve-ak.last.fm/serve/252/218364.jpg<br />
2011-04-15 19:43:59,383 (-4f9e9000) :  INFO (core) - id: Sixpence%20None%20the%20Richer%20and%20Jars%20of%20Clay  name: Sixpence None the Richer and Jars of Clay   score: 84   thumb: http://userserve-ak.last.fm/serve/252/49256771.jpg<br />
2011-04-15 19:43:59,384 (-4f9e9000) :  INFO (core) - id: None%20Shall%20Be%20Saved  name: None Shall Be Saved   score: 82   thumb: http://userserve-ak.last.fm/serve/252/4804.jpg<br />
2011-04-15 19:43:59,384 (-4f9e9000) :  INFO (core) - id: Lose%20None  name: Lose None   score: 80   thumb: http://userserve-ak.last.fm/serve/252/2621953.jpg<br />
2011-04-15 19:43:59,385 (-4f9e9000) :  INFO (core) - id: None%20Other  name: None Other   score: 78   thumb: http://userserve-ak.last.fm/serve/252/2506761.jpg<br />
2011-04-15 19:43:59,385 (-4f9e9000) :  INFO (core) - id: None%20of%20the%20Above  name: None of the Above   score: 76   thumb: http://userserve-ak.last.fm/serve/252/49291607.jpg<br />
2011-04-15 19:43:59,385 (-4f9e9000) :  INFO (core) - id: Sixpence%20None%20The%20Richer%20%28Holiday%29  name: Sixpence None The Richer (Holiday)   score: 74   thumb: http://userserve-ak.last.fm/serve/252/56222333.png<br />
2011-04-15 19:43:59,386 (-4f9e9000) :  INFO (core) - id: Second%20To%20None  name: Second To None   score: 72   thumb: http://userserve-ak.last.fm/serve/252/3556193.jpg<br />
2011-04-15 19:43:59,386 (-4f9e9000) :  INFO (core) - id: None%20Left%20Standing  name: None Left Standing   score: 70   thumb: http://userserve-ak.last.fm/serve/252/396293.jpg<br />
2011-04-15 19:43:59,387 (-4f9e9000) :  INFO (core) - id: None%20Nedelkovska  name: None Nedelkovska   score: 68   thumb: http://userserve-ak.last.fm/serve/252/22434183.jpg<br />
2011-04-15 19:43:59,387 (-4f9e9000) :  INFO (core) - id: %28none%29  name: (none)   score: 66   thumb: None<br />
2011-04-15 19:43:59,388 (-4f9e9000) :  INFO (core) - id: Format%20None  name: Format None   score: 64   thumb: http://userserve-ak.last.fm/serve/252/40526701.jpg<br />
2011-04-15 19:43:59,388 (-4f9e9000) :  INFO (core) - id: none%20the%20less  name: none the less   score: 62   thumb: http://userserve-ak.last.fm/serve/252/5431731.jpg<br />
2011-04-15 19:43:59,388 (-4f9e9000) :  INFO (core) - id: Sixpence%20None%20the%20Richer%20and%20Bebo%20Norman  name: Sixpence None the Richer and Bebo Norman   score: 60   thumb: None<br />
2011-04-15 19:43:59,389 (-4f9e9000) :  INFO (core) - id: God.Fear.None  name: God.Fear.None   score: 58   thumb: http://userserve-ak.last.fm/serve/252/7907095.jpg<br />
2011-04-15 19:43:59,389 (-4f9e9000) :  INFO (core) - id: DJ%20Quik%20featuring%20Snoop%20Dogg%2C%20Nate%20Dogg%2C%20AMG%2C%202nd%20II%20None%2C%20Hi-C%20%26%20El%20DeBarge  name: DJ Quik featuring Snoop Dogg, Nate Dogg, AMG, 2nd II None, Hi-C & El DeBarge   score: 56   thumb: None<br />
2011-04-15 19:43:59,390 (-4f9e9000) :  INFO (core) - id: Company%20of%20None  name: Company of None   score: 54   thumb: None<br />
2011-04-15 19:43:59,390 (-4f9e9000) :  INFO (core) - id: 2nd2none  name: 2nd2none   score: 52   thumb: http://userserve-ak.last.fm/serve/252/59438049.jpg<br />
2011-04-15 19:43:59,390 (-4f9e9000) :  INFO (core) - id: %3CNone%3E  name: <None>   score: 50   thumb: None<br />
2011-04-15 19:43:59,391 (-4f9e9000) :  INFO (core) - id: Leigh%20Nash%20of%20Sixpence%20None%20the%20Richer  name: Leigh Nash of Sixpence None the Richer   score: 48   thumb: None<br />
2011-04-15 19:43:59,391 (-4f9e9000) :  INFO (core) - id: %5BNone%5D  name: [None]   score: 46   thumb: None<br />
2011-04-15 19:43:59,392 (-4f9e9000) :  INFO (core) - id: -none-  name: -none-   score: 44   thumb: None<br />
2011-04-15 19:43:59,392 (-4f9e9000) :  INFO (core) - id: Hybrid%20None  name: Hybrid None   score: 42   thumb: http://userserve-ak.last.fm/serve/252/44319217.jpg<br />
2011-04-15 19:43:59,406 (-4f9e9000) :  DEBUG (core) - Response: 200<br />




The log above was created while searching for artistinfo about Metallica. I looks like media.artist contains "none" or something like that. Since I didn't modify the code to collect data I'm wondering why media.artist contains in this case a false string while the same code in the original lastFM-agent works fine.

Anyone has an idea whats going wrong?

Thanks!

I don’t have any solution. Just to add me to the problem that you are having.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.