ZeroQI / YouTube-Agent.bundle

Plex Metadata Agent for Movies and TV Series libraries
452 stars 43 forks source link

AttributeError: 'NoneType' object has no attribute 'rfind' #45

Closed ghost closed 3 years ago

ghost commented 3 years ago

After updating to the latest git version I receive the following error when attempting to match content: https://pastebin.com/F1HL2Mfu

Metadata is also not populating even when the logs seem to show the agent is pulling the info.

ZeroQI commented 3 years ago

'YouTubeSeries', called with keyword arguments {'show': '[UC88lvyJe7aHZmcvzvubDFRg]', 'id': '1090242', 'year': None}

There's no title... Once the force is is removed, there's nothing left ...

skjnldsv commented 3 years ago
2020-11-21 17:45:10,304 (148b56eed700) :  CRITICAL (agentkit:1018) - Exception in the search function of agent named 'YouTubeSeries', called with keyword arguments {'show': "C'est Pas Sorcier", 'id': '103856', 'year': None} (most recent call last):
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-47c0d9038/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1011, in _search
    agent.search(*f_args, **f_kwargs)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 676, in search
    def search (self, results,  media, lang, manual):  Search (results,  media, lang, manual, False)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 200, in Search
    search_from_info_json(results, media, lang, movie)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 174, in search_from_info_json
    filename    = os.path.basename(media.items[0].parts[0].file) if movie else os.path.splitext(os.path.basename(media.filename))[0]
  File "/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/posixpath.py", line 114, in basename
    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

@ZeroQI it does it with title too. My folders are named properly, it fails on master. Would you consider reopening? :)

PS/ I'm using the same pattern as your readme "%(uploader)s [%(channel_id)s]/%(playlist_index)s - %(title)s [%(id)s].%(ext)s"

ZeroQI commented 3 years ago

@skjnldsv I will need the youtube logs to pinpoint where it goes wrong, as i do not use the agent for myself, and do not have access to my plex server...

skjnldsv commented 3 years ago

I will need the youtube logs to pinpoint where it goes wrong, as i do not use the agent for myself, and do not have access to my plex server...

Of course :)

2020-11-22 11:35:17,921 (154d2e89e700) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.agents.youtube/messaging/function/X0FnZW50S2l0OlNlYXJjaA__/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoyCmRpY3QKZGljdAo2CnMyCnhuczQKbGFuZ2IxczYKbWFudWFsYjFzNwpwcmltYXJ5aTAKczcKdmVyc2lvbnIxCnM2Cmt3YXJnc3M3ClRWX1Nob3dzMTAKbWVkaWFfdHlwZTMKbnM0CnllYXJzNgoxMDM4NTZzMgppZHMxNwpDJ2VzdCBQYXMgU29yY2llcnM0CnNob3dyMAo_
2020-11-22 11:35:17,922 (154d2e89e700) :  DEBUG (runtime:49) - Received packed state data (80 bytes)
2020-11-22 11:35:17,923 (154d2e89e700) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.agents.youtube/messaging/function/X0FnZW50S2l0OlNlYXJjaA__/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoyCmRpY3QKZGljdAo2CnMyCnhuczQKbGFuZ2IxczYKbWFudWFsYjFzNwpwcmltYXJ5aTAKczcKdmVyc2lvbnIxCnM2Cmt3YXJnc3M3ClRWX1Nob3dzMTAKbWVkaWFfdHlwZTMKbnM0CnllYXJzNgoxMDM4NTZzMgppZHMxNwpDJ2VzdCBQYXMgU29yY2llcnM0CnNob3dyMAo_
2020-11-22 11:35:17,924 (154d2e89e700) :  INFO (agentkit:961) - Searching for matches for {'show': "C'est Pas Sorcier", 'id': '103856', 'year': None}
2020-11-22 11:35:17,925 (154d2e89e700) :  DEBUG (networking:143) - Requesting 'http://127.0.0.1:32400/library/metadata/103856/tree'
2020-11-22 11:35:18,588 (154d2e89e700) :  CRITICAL (agentkit:1018) - Exception in the search function of agent named 'YouTubeSeries', called with keyword arguments {'show': "C'est Pas Sorcier", 'id': '103856', 'year': None} (most recent call last):
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-47c0d9038/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1011, in _search
    agent.search(*f_args, **f_kwargs)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 676, in search
    def search (self, results,  media, lang, manual):  Search (results,  media, lang, manual, False)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 200, in Search
    search_from_info_json(results, media, lang, movie)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 174, in search_from_info_json
    filename    = os.path.basename(media.items[0].parts[0].file) if movie else os.path.splitext(os.path.basename(media.filename))[0]
  File "/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/posixpath.py", line 114, in basename
    i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

2020-11-22 11:35:18,592 (154d2e89e700) :  DEBUG (runtime:88) - Sending packed state data (107 bytes)
2020-11-22 11:35:18,592 (154d2e89e700) :  DEBUG (runtime:924) - Response: [200] str, 16 bytes
skjnldsv commented 3 years ago

And a second one that looks a bit different :thinking:

2020-11-22 11:37:30,866 (154d2e89e700) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.agents.youtube/messaging/function/X0FnZW50S2l0OlNlYXJjaA__/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoyCmRpY3QKZGljdAo2CnMyCnhuczQKbGFuZ2IxczYKbWFudWFsYjFzNwpwcmltYXJ5aTAKczcKdmVyc2lvbnIxCnM2Cmt3YXJnc3M3ClRWX1Nob3dzMTAKbWVkaWFfdHlwZTkKczE2CmRkZGIwYjQ3ODdjNzhjMDlzMTcKb3BlblN1YnRpdGxlc0hhc2hzMgo3NnM3CmVwaXNvZGVzMQoxczgKZXBpc29kaWNzMTcKQydlc3QgUGFzIFNvcmNpZXJzNApzaG93czEKNnM2CnNlYXNvbnMxNjYKJTJGeW91dHViZSUyRkMlMjdlc3QlMjBwYXMlMjBzb3JjaWVyJTIwJTVCVUNFTnY4cEg0TGt6dnVTVl9xSEljc2xnJTVEJTJGMzUlMjAtJTIwQyUyN2VzdCUyMHBhcyUyMHNvcmNpZXIlMjAtU09SQ0lFUlMlMjBTRSUyMEZPTlQlMjBMQSUyME1BSU4lMjAlNUJXTDZ4NzZXenFDWSU1RCUyRW1rdnM4CmZpbGVuYW1lczQwCmEyN2RhNjgzN2VkNjBmMjZlZTA3YzIwZWMzZTZlNGRkYjNkMTE2NmVzOApwbGV4SGFzaHM3CjE1Njc2MjFzOApkdXJhdGlvbnM2CjEwMzg1NnMyCmlkcjAK
2020-11-22 11:37:30,867 (154d2e89e700) :  DEBUG (runtime:49) - Received packed state data (80 bytes)
2020-11-22 11:37:30,868 (154d2e89e700) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.agents.youtube/messaging/function/X0FnZW50S2l0OlNlYXJjaA__/Y2VyZWFsMQoxCmxpc3QKMApyMAo_/Y2VyZWFsMQoyCmRpY3QKZGljdAo2CnMyCnhuczQKbGFuZ2IxczYKbWFudWFsYjFzNwpwcmltYXJ5aTAKczcKdmVyc2lvbnIxCnM2Cmt3YXJnc3M3ClRWX1Nob3dzMTAKbWVkaWFfdHlwZTkKczE2CmRkZGIwYjQ3ODdjNzhjMDlzMTcKb3BlblN1YnRpdGxlc0hhc2hzMgo3NnM3CmVwaXNvZGVzMQoxczgKZXBpc29kaWNzMTcKQydlc3QgUGFzIFNvcmNpZXJzNApzaG93czEKNnM2CnNlYXNvbnMxNjYKJTJGeW91dHViZSUyRkMlMjdlc3QlMjBwYXMlMjBzb3JjaWVyJTIwJTVCVUNFTnY4cEg0TGt6dnVTVl9xSEljc2xnJTVEJTJGMzUlMjAtJTIwQyUyN2VzdCUyMHBhcyUyMHNvcmNpZXIlMjAtU09SQ0lFUlMlMjBTRSUyMEZPTlQlMjBMQSUyME1BSU4lMjAlNUJXTDZ4NzZXenFDWSU1RCUyRW1rdnM4CmZpbGVuYW1lczQwCmEyN2RhNjgzN2VkNjBmMjZlZTA3YzIwZWMzZTZlNGRkYjNkMTE2NmVzOApwbGV4SGFzaHM3CjE1Njc2MjFzOApkdXJhdGlvbnM2CjEwMzg1NnMyCmlkcjAK
2020-11-22 11:37:30,869 (154d2e89e700) :  INFO (agentkit:961) - Searching for matches for {'openSubtitlesHash': 'dddb0b4787c78c09', 'episode': '76', 'episodic': '1', 'show': "C'est Pas Sorcier", 'season': '6', 'filename': '%2Fyoutube%2FC%27est%20pas%20sorcier%20%5BUCENv8pH4LkzvuSV_qHIcslg%5D%2F35%20-%20C%27est%20pas%20sorcier%20-SORCIERS%20SE%20FONT%20LA%20MAIN%20%5BWL6x76WzqCY%5D%2Emkv', 'plexHash': 'a27da6837ed60f26ee07c20ec3e6e4ddb3d1166e', 'duration': '1567621', 'id': '103856'}
2020-11-22 11:37:30,870 (154d2e89e700) :  DEBUG (networking:143) - Requesting 'http://127.0.0.1:32400/library/metadata/103856/tree'
2020-11-22 11:37:31,583 (154d2e89e700) :  INFO (__init__:61) - /youtube/C'est pas sorcier [UCENv8pH4LkzvuSV_qHIcslg]/24 - C'est pas sorcier - Louvre 1  - du château fort au grand musée [617_B-rHzLc].mkv
2020-11-22 11:37:31,587 (154d2e89e700) :  INFO (__init__:177) - =============================================================================================================================================================
2020-11-22 11:37:31,587 (154d2e89e700) :  INFO (__init__:178) - search_metadata_from_info_json() - dir: /youtube/C'est pas sorcier [UCENv8pH4LkzvuSV_qHIcslg], filename: /youtube/C'est pas sorcier [UCENv8pH4LkzvuSV_qHIcslg]/35 - C'est pas sorcier -SORCIERS SE FONT LA MAIN [WL6x76WzqCY].mkv
2020-11-22 11:37:31,587 (154d2e89e700) :  INFO (__init__:181) - searching for info file - dir: /youtube/C'est pas sorcier [UCENv8pH4LkzvuSV_qHIcslg], json_filename: /youtube/C'est pas sorcier [UCENv8pH4LkzvuSV_qHIcslg]/35 - C'est pas sorcier -SORCIERS SE FONT LA MAIN [WL6x76WzqCY].info.json
2020-11-22 11:37:31,588 (154d2e89e700) :  CRITICAL (agentkit:1018) - Exception in the search function of agent named 'YouTubeSeries', called with keyword arguments {'openSubtitlesHash': 'dddb0b4787c78c09', 'episode': '76', 'episodic': '1', 'show': "C'est Pas Sorcier", 'season': '6', 'filename': '%2Fyoutube%2FC%27est%20pas%20sorcier%20%5BUCENv8pH4LkzvuSV_qHIcslg%5D%2F35%20-%20C%27est%20pas%20sorcier%20-SORCIERS%20SE%20FONT%20LA%20MAIN%20%5BWL6x76WzqCY%5D%2Emkv', 'plexHash': 'a27da6837ed60f26ee07c20ec3e6e4ddb3d1166e', 'duration': '1567621', 'id': '103856'} (most recent call last):
  File "/usr/lib/plexmediaserver/Resources/Plug-ins-47c0d9038/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1011, in _search
    agent.search(*f_args, **f_kwargs)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 676, in search
    def search (self, results,  media, lang, manual):  Search (results,  media, lang, manual, False)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 200, in Search
    search_from_info_json(results, media, lang, movie)
  File "/config/Library/Application Support/Plex Media Server/Plug-ins/YouTube-Agent.bundle/Contents/Code/__init__.py", line 183, in search_from_info_json
    with open(json_filename) as f:
IOError: [Errno 2] No such file or directory: "/youtube/C'est pas sorcier [UCENv8pH4LkzvuSV_qHIcslg]/35 - C'est pas sorcier -SORCIERS SE FONT LA MAIN [WL6x76WzqCY].info.json"

2020-11-22 11:37:31,592 (154d2e89e700) :  DEBUG (runtime:88) - Sending packed state data (107 bytes)
2020-11-22 11:37:31,592 (154d2e89e700) :  DEBUG (runtime:924) - Response: [200] str, 16 bytes
ZeroQI commented 3 years ago

@skjnldsv Oh putain, ca remontes loin cette emission...

First bug it seems the filename cause an issue line 174 filename = os.path.basename(media.items[0].parts[0].file) if movie else os.path.splitext(os.path.basename(media.filename))[0] in the part os.path.splitext(os.path.basename(media.filename))[0] but would need the filename, but may be pointing at the wrong line of code...

Last bug report (prob json file saved but rights issue): https://github.com/ZeroQI/YouTube-Agent.bundle/blob/master/Contents/Code/__init__.py lines 183-184, replace with:

  try:
    with open(json_filename) as f:
      video_details = JSON.ObjectFromString(f.read())
  except:  return
skjnldsv commented 3 years ago

Last bug report (prob json file saved but rights issue): https://github.com/ZeroQI/YouTube-Agent.bundle/blob/master/Contents/Code/init.py lines 183-184, replace with:

  try:
    with open(json_filename) as f:
      video_details = JSON.ObjectFromString(f.read())
  except:  return

Works now! :)

@skjnldsv Oh putain, ca remontes loin cette emission...

The very best! :ok_hand: :grin:

ZeroQI commented 3 years ago

Honestly a very good program to learn French if not native and instructive in all cases... Still need to solve hte first bug. Added to master branch the code