Skip to content

Commit

Permalink
Add fallback request with stripped year for thetvdb
Browse files Browse the repository at this point in the history
  • Loading branch information
Renatochaz committed Jun 26, 2024
1 parent bb684a2 commit 792aa97
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Contents/Code/TheTVDBv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,12 @@ def Search(results, media, lang, manual, movie): #if maxi<50: maxi = tvdb.Sea
#series_data = JSON.ObjectFromString(GetResultFromNetwork(TVDB_SEARCH_URL % mediaShowYear, additionalHeaders={'Accept-Language': lang}))['data'][0]
orig_title = ( media.title if movie else media.show )
maxi = 0
try: TVDBsearchXml = XML.ElementFromURL( TVDB_SERIE_SEARCH + quote(orig_title), headers=common.COMMON_HEADERS, cacheTime=CACHE_1HOUR * 24)
try:
TVDBsearchXml = XML.ElementFromURL( TVDB_SERIE_SEARCH + quote(orig_title), headers=common.COMMON_HEADERS, cacheTime=CACHE_1HOUR * 24)
if not TVDBsearchXml.xpath('Series'):
# Do a second try with the year removed from the title, if any
orig_title = re.sub(r'\s*\(\d{4}\)$', '', orig_title)
TVDBsearchXml = XML.ElementFromURL( TVDB_SERIE_SEARCH + quote(orig_title), headers=common.COMMON_HEADERS, cacheTime=CACHE_1HOUR * 24)
except Exception as e: Log.Error("TVDB Loading search XML failed, Exception: '%s'" % e)
else:
for serie in TVDBsearchXml.xpath('Series'):
Expand Down

0 comments on commit 792aa97

Please sign in to comment.