my apologies, i just saw the difference.
try:
the_dir = os.path.dirname(files[0])
if os.path.exists(the_dir + '//' + 'tvdb.id'):
fo = open(os.path.realpath(the_dir + '//' + 'tvdb.id'),'rb')
tvdb_id = fo.readline()
# Added per evardjp's comment - this fixes issues when working in Windows and a newline is added
tvdb_id = tvdb_id.replace("
","").replace("\r","").replace(" ","")
episode_dict = GetEpisodesBySeriesID(tvdb_id)
sortToSeasons = True
except:
pass
if the file exists, calls the mapping function. that's where i would flex it since the variables are define there
modify to the line episode_num = el_text(episode_el,'absolute_number')
def GetEpisodesBySeriesID( seriesID):
# Convenience function
el_text = lambda element, xp: element.xpath(xp)[0].text if element.xpath(xp)[0].text else ''
Get the show’s zipped data
zip_url = TVDB_ZIP_URL % (Dict[‘ZIP_MIRROR’], seriesID, lang)
zip_data = cStringIO.StringIO(GetResultFromNetwork(zip_url).read())
with zipfile.ZipFile(zip_data) as zip_archive:
zip_archive_mem = cStringIO.StringIO(zip_archive.read(lang+’.xml’))
zip_archive_mem = zip_archive_mem.read()
#Test to make sure file is correct
#f = open(’//media//IDRIVE//en.xml’, ‘w’)
#f.write(zip_archive_mem)
#zip_archive = Archive.Zip(zip_data)
Extract the XML files from the archive. Work around corrupt XML.
root_el = etree.fromstring(fixBrokenXml(zip_archive_mem))
series_el = root_el.xpath(‘Episode’)
Get list of all episodes and match their season/episode number to absolute number
#Store the results in a dict so we can look for the season/episode for a particular absolute number
episode_dict = dict()
for episode_el in series_el:
absolute_num = el_text(episode_el, ‘absolute_number’)
season_num = el_text(episode_el, ‘SeasonNumber’)
episode_num = el_text(episode_el,‘absolute_number’) # was EpisodeNumber
#We only store the episode in dictionary if it has an absolute number
if absolute_num.isdigit():
episode_dict[int(absolute_num)] = [season_num, episode_num]
return episode_dict
good luck