def get_sub_item(item): l = [] ret = 0 search_str = get_search_string(item) try: l.extend(unacs.read_sub(search_str, item['year'])) except Exception as e: log_my('unacs.read_sub', str(e)) update(os.path.basename(item['file_original_path']), 'exception', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % item, sys.exc_info() ) ret += 1 try: l.extend(subs_sab.read_sub(search_str, item['year'])) except Exception as e: log_my('subs_sab.read_sub', str(e)) update(os.path.basename(item['file_original_path']), 'exception', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % item, sys.exc_info() ) ret += 2 if ret == 3: return None return l
def read_sub(*items): l = [] update( os.path.basename(items[0]['file_original_path']), 'subs_search', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % items[0]) for item in items: search_str = get_search_string(item) try: ll = unacs.read_sub(search_str, item['year']) if ll: l.extend(ll) except Exception as e: log_my('unacs.read_sub', str(e)) update( os.path.basename(item['file_original_path']), 'exception', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % item, sys.exc_info()) try: ll = subs_sab.read_sub(search_str, item['year']) if ll: l.extend(ll) except Exception as e: log_my('subs_sab.read_sub', str(e)) update( os.path.basename(item['file_original_path']), 'exception', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % item, sys.exc_info()) if not l: return None return [i for n, i in enumerate(l) if i not in l[:n]]
def get_sub_item(item): l = [] ret = 0 search_str = get_search_string(item) try: l.extend(unacs.read_sub(search_str, item["year"])) except Exception as e: log_my("unacs.read_sub", str(e)) update( os.path.basename(item["file_original_path"]), "exception", "title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s" % item, sys.exc_info(), ) ret += 1 try: l.extend(subs_sab.read_sub(search_str, item["year"])) except Exception as e: log_my("subs_sab.read_sub", str(e)) update( os.path.basename(item["file_original_path"]), "exception", "title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s" % item, sys.exc_info(), ) ret += 2 if ret == 3: return None return l
def read_sub(*items): l = [] update(os.path.basename(items[0]['file_original_path']), 'subs_search', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % items[0] ) for item in items: search_str = get_search_string(item) try: ll = unacs.read_sub(search_str, item['year']) if ll: l.extend(ll) except Exception as e: log_my('unacs.read_sub', str(e)) update(os.path.basename(item['file_original_path']), 'exception', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % item, sys.exc_info() ) try: ll = subs_sab.read_sub(search_str, item['year']) if ll: l.extend(ll) except Exception as e: log_my('subs_sab.read_sub', str(e)) update(os.path.basename(item['file_original_path']), 'exception', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % item, sys.exc_info() ) if not l: return None return [i for n,i in enumerate(l) if i not in l[:n]]
def read_sub(*items): l = [] (os.path.basename(items[0]['file_original_path']), 'subs_search', 'title:%(title)s,tvshow:%(tvshow)s,season:%(season)s,episode:%(episode)s' % items[0] ) for item in items: search_str = get_search_string(item) if ' / ' in search_str: search_str = re.sub(r' /.*','',search_str) if __addon__.getSetting('unacscom') == 'true': try: ll = unacs.read_sub(search_str, item['year']) if ll: l.extend(ll) except Exception as e: log_my('unacs.read_sub', str(e)) else: __addon__.getSetting('unacscom') == 'false' if __addon__.getSetting('sab_bz') == 'true': try: ll = subs_sab.read_sub(search_str, item['year']) if ll: l.extend(ll) except Exception as e: log_my('subs_sab.read_sub', str(e)) else: __addon__.getSetting('sab_bz') == 'false' if __addon__.getSetting('yavkanet') == 'true': try: #tv series fix search_yavka = re.sub('(\d{1,2})x(\d{1,2})', lambda x: "- S{}E{}".format((x.group(1).zfill(2)),x.group(2).zfill(2)),search_str) ll = yavka.read_sub(search_yavka, item['year']) if ll: l.extend(ll) except Exception as e: log_my('yavka.read_sub', str(e)) else: __addon__.getSetting('yavkanet') == 'false' if __addon__.getSetting('bukvibg') == 'true': try: ll = bukvi.read_sub(search_str) if ll: l.extend(ll) except Exception as e: log_my('bukvi.read_sub', str(e)) else: __addon__.getSetting('bukvibg') == 'false' if __addon__.getSetting('easternspiritorg') == 'true': try: ll = easternspirit.read_sub(search_str) if ll: l.extend(ll) except Exception as e: log_my('easternspirit.read_sub', str(e)) else: __addon__.getSetting('easternspiritorg') == 'false' if not l: return None return [i for n,i in enumerate(l) if i not in l[:n]]
def read_sub (item): l = unacs.read_sub(item) l += subs_sab.read_sub(item) return l
if __name__ == "__main__": cnt = len(sys.argv) item ={'m':'', 'title':'', 'year':'', 'file_original_path':'' } if cnt == 3: item['year'] = sys.argv[2] elif cnt == 1: sys.exit(1) item['title'] = sys.argv[1] l = unacs.read_sub(item) l += subs_sab.read_sub(item) tmp ='' for ll in l: tmp = tmp + get_info(ll)+'>>>>'+'\n' savetofile(tmp, 'out.txt') log_my(l[-1]['url']) if l[-1]['id'] == 'unacs': r=unacs.get_sub(None, l[-1]['url'], None) else: r=subs_sab.get_sub(None, l[-1]['url'], None) if (r.has_key('data') and r.has_key('fname')):