mmmmmtasty / SportScanner

Scanner and Metadata Agent for Plex that uses sportdb
115 stars 31 forks source link

Missing Match: Line 279: UnboundLocalError: local variable 'valid_names' referenced before assignment #7

Closed rickjtaylor closed 8 years ago

rickjtaylor commented 9 years ago

Getting close! Of the 10 files in there, this time, only 1 did not process.

Filename: NBA_2010-11-06_Utah_Jazz_vs_Los_Angeles_Clippers.m4v Again, http://www.thesportsdb.com/api/v1/json/1/searchfilename.php?e=NBA_2010-11-06_Utah_Jazz_vs_Los_Angeles_Clippers, finds it properly.

Error in console: 2015-11-16 13:06:29,078 (700002dbb000) : CRITICAL (runtime:298) - Exception in task thread (most recent call last): File "bundles-release/Framework.bundle-dist/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 296, in _start File "bundles-release/Framework.bundle-dist/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 243, in _exec File "/Users/Plex/Library/Application Support/Plex Media Server/Plug-ins/SportScanner.bundle/Contents/Code/init.py", line 279, in UpdateEpisode episode.thumbs.validate_keys(valid_names) UnboundLocalError: local variable 'valid_names' referenced before assignment

A very quick aside: This could be my expectations of how Plex functions, not an issue. But each time you've tweaked things, I've first tried to "Refresh" the offending non-match (after updating the scanner and restarting PMS). It never works. I have to kill the library altogether and re-create and reprocess. Again, is that a mis-expectation on my part, or another potential issue?

mmmmmtasty commented 9 years ago

Sorry I messed up my previous commit. I've committed again fixing this issue and also I now use the filename search to speed some matches up.

Please report back if this is working for you, I'll leave this issue open for now waiting for your feedback!

As far as refreshing goes I've had a similar experience. I know plex doesn't bother checking out directories if nothing has changed in them, but a force refresh on the item should do the trick. I've noticed some issues with this as well. Perhaps I've missed something, I'll have another look into it.

rickjtaylor commented 9 years ago

OK, I still have a problem with that same file. However, I don't think this one is the scanner. Check this out:

This works: http://www.thesportsdb.com/api/v1/json/1/searchfilename.php?e=NBA_2010-11-06_Utah_Jazz_vs_Los_Angeles_Clippers

This does NOT work (extension added) http://www.thesportsdb.com/api/v1/json/1/searchfilename.php?e=NBA_2010-11-06_Utah_Jazz_vs_Los_Angeles_Clippers.m4v

The odd thing is, I don't see any difference between this and the others in the log. Thesportsdb.com definitely does NOT like the extension, for any file. However, the log seems to indicate that you are passing it in every case, and yet 9 of 10 work perfectly. I don't get. I'm sure you do :)

Eagle

mmmmmtasty commented 9 years ago

Don't be so sure ;)

I'll take a look.

mmmmmtasty commented 9 years ago

What OS are you running Plex on? On my (Windows 10) machine os.path.basename(path) seems to return a filename without the extension so the URL is correctly formed. That is NOT what os.path.basename(path) is supposed to do though according to the documentation, extension should be included...

I've updated the code to split the extension off and it still works for me in the same way, could you let me know if it works for you? If not could you please attach the complete log file?

Thanks

MmmmmTasty

rickjtaylor commented 9 years ago

Not quite there. Oh so close.

Again, I deleted and recreated my library. Strangely, it's the same file is bombing, though it appears to be a simple type mismatch now. See the log.

Also, my server is OS X.

Thanks!

com.plexapp.agents.sportscanner.txt

mmmmmtasty commented 9 years ago

And try again? Sorry for this, I did a couple of stupid things on the way through that I could have tested slightly better.

rickjtaylor commented 8 years ago

Still an issue. Here's the latest error and full log:

2015-11-18 05:22:58,849 (700002dbb000) : CRITICAL (runtime:298) - Exception in task thread (most recent call last): File "bundles-release/Framework.bundle-dist/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 296, in _start File "bundles-release/Framework.bundle-dist/Contents/Resources/Versions/2/Python/Framework/components/runtime.py", line 243, in _exec File "/Users/Rick/Library/Application Support/Plex Media Server/Plug-ins/SportScanner.bundle/Contents/Code/init.py", line 282, in UpdateEpisode episode.summary = season_metadata['events'][closest_event]['strAwayTeam']+" ("+season_metadata['events'][closest_event]['intAwayScore']+") at "+season_metadata['events'][closest_event]['strHomeTeam']+" ("+season_metadata['events'][closest_event]['intHomeScore']+")\r\n\r\n"+season_metadata['events'][closest_event]['strDescriptionEN'] UnboundLocalError: local variable 'closest_event' referenced before assignment

com.plexapp.agents.sportscanner.txt

mmmmmtasty commented 8 years ago

I, uh, think this one might be you? The following line is not in the code that I committed so I think you have added it?

episode.summary = season_metadata['events'][closest_event]['strAwayTeam']+" ("+season_metadata['events'][closest_event]['intAwayScore']+") at "+season_metadata['events'][closest_event]['strHomeTeam']+" ("+season_metadata['events'][closest_event]['intHomeScore']+")\r\n\r\n"+season_metadata['events'][closest_event]['strDescriptionEN']

It looks like you are trying to make the description a little more descriptive which is fine, but I have taken the closest_event variable out of that scope, hence the error.

If you replace "season_metadata['events'][closest_event]" with "matched_episode" it should work for you but I'd prefer to add this upstream.

Please confirm that it works without this change and I will close this issue.

Thanks

rickjtaylor commented 8 years ago

Close this sucker!

Working like a charm. Sorry for my little snafu. Shouldn't have been messing with the stuff while testing. I was simultaneously testing the ability to "refresh" metadata for an existing game. I'm going to open another issue for that.

Happy camper, Eagle