Skip to content

exception when exporting certain titles #801

@ensc

Description

@ensc

Addon used

  • Amazon VOD (plugin.video.amazon-test)
  • Browser Launcher (plugin.program.browser.launcher)
  • Addon version:

Account type

  • primevideo.com
  • amazon.(com/co.uk/de/jp)

System Setup (please provide the following information):

  • Hardware: Amazon FireTV
  • OS version:
  • Kodi version number: 21.3

Upload Logs

2025-12-21 16:56:48.033 T:14727    info <general>: [Amazon VOD] Export: The Last of Us - S02E150 - The Last of Us: Ellie's Journey to Season 2
2025-12-21 16:56:48.152 T:14727   error <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'TypeError'>
                                                   Error Contents: fromisoformat: argument must be str
                                                   Traceback (most recent call last):
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/default.py", line 9, in <module>
                                                       EntryPoint(argv)
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/startup.py", line 81, in EntryPoint
                                                       _g.pv.getPage(_g.watchlist, export=2)
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/android_api.py", line 150, in getPage
                                                       addDir(k, 'getPage', page, opt=urlencode(v), export=export)
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/itemlisting.py", line 50, in addDir
                                                       exec(f'_g.pv.{mode}("{url}", "{opt}", {page}, export={export})')
                                                     File "<string>", line 1, in <module>
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/android_api.py", line 257, in getPage
                                                       addDir(self.formatTitle(il), 'getPage', 'details', infoLabels=il, opt='itemId=' + il['asins'], cm=cm, page=pgnr, export=export)
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/itemlisting.py", line 50, in addDir
                                                       exec(f'_g.pv.{mode}("{url}", "{opt}", {page}, export={export})')
                                                     File "<string>", line 1, in <module>
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/android_api.py", line 168, in getPage
                                                       addDir(self.formatTitle(il), 'getPage', 'details', il, 'itemId=' + il['asins'], cm=cm, export=export)
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/itemlisting.py", line 50, in addDir
                                                       exec(f'_g.pv.{mode}("{url}", "{opt}", {page}, export={export})')
                                                     File "<string>", line 1, in <module>
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/android_api.py", line 174, in getPage
                                                       addVideo(self.formatTitle(il), il['asins'], il, cm=cm, export=export)
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/itemlisting.py", line 117, in addVideo
                                                       Export(infoLabels, url)
                                                     File "/storage/emulated/0/Android/data/org.xbmc.kodi/files/.kodi/addons/plugin.video.amazon-test/resources/lib/export.py", line 21, in Export
                                                       isAired = datetime.date.today() >= datetime.date.fromisoformat(infoLabels.get('premiered', '1970-01-01'))
                                                                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                                                   TypeError: fromisoformat: argument must be str
                                                   -->End of Python script error report<--

Describe the bug

Trying to export certain titles fails with the exception above. This happens because the premiered field has a value of None; e.g. adding debugging at

https://github.com/Sandmann79/xbmc/blob/master/plugin.video.amazon-test/resources/lib/export.py#L21

shows that infoLabels has the content

{'plot': 'Bella ...', 'mpaa': None, 'cast': [], 'year': None, 'premiered': None, 'rating': None, 'votes': 0, 'isAdult': 0, 'director': None, 'genre': ['Drama', 'Fantasy', 'Sci-Fi/Fantasy'], 'studio': ['Discovery Global Drama'], 'thumb': 'https://... 'fanart': 'https://...', 'isHD': False, 'isUHD': False, 'audiochannels': 2, 'TrailerAvailable': False, 'asins': 'amzn1.dv.gti....', 'isPrime': False, 'title': 'The Last of Us: Character Featurette - Ellie', 'contentType': 'episode', 'mediatype': 'episode', 'tvshowtitle': 'The Last of Us', 'seriesasin': 'amzn1.dv.gti.....', 'totalseasons': 2, 'season': 2, 'duration': 49, 'episode': 153}

Writing

diff --git a/plugin.video.amazon-test/resources/lib/export.py b/plugin.video.amazon-test/resources/lib/export.py
index 85d5188..5c7a2d0 100644
--- a/plugin.video.amazon-test/resources/lib/export.py
+++ b/plugin.video.amazon-test/resources/lib/export.py
@@ -18,7 +18,7 @@ _g = Globals()
 def Export(infoLabels, url):
     isEpisode = infoLabels['contentType'] != 'movie'
     isEvent = 'tvshowtitle' not in infoLabels and isEpisode
-    isAired = datetime.date.today() >= datetime.date.fromisoformat(infoLabels.get('premiered', '1970-01-01'))
+    isAired = datetime.date.today() >= datetime.date.fromisoformat(infoLabels.get('premiered') or '1970-01-01')
     language = xbmc.convertLanguage(_s.Language, xbmc.ISO_639_2)
     ExportPath = _s.MOVIE_PATH
     nfoType = 'movie'

fixes it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions