diff --git a/Contents/Code/common.py b/Contents/Code/common.py index 03ed7e8..8a39d5f 100644 --- a/Contents/Code/common.py +++ b/Contents/Code/common.py @@ -315,7 +315,14 @@ def GetEmoji(type, mode='vibrant', session=None): if session == None: session = getSession() - if mode == 'simple' and (UsingOption(DEVICE_OPTIONS[3], session=session) or UsingOption(DEVICE_OPTIONS[4], session=session)): + if mode == 'txt': + if type == 'pos' or type == 'true': + return EMOJI_TXT_POS + elif type =='neg' or type == 'false': + return EMOJI_TXT_NEG + else: + return EMOJI_TXT_QUES + elif mode == 'simple' and (UsingOption(DEVICE_OPTIONS[3], session=session) or UsingOption(DEVICE_OPTIONS[4], session=session)): if type == 'pos' or type == 'true': return EMOJI_TICK elif type =='neg' or type == 'false': diff --git a/Contents/Code/downloadsmenu.py b/Contents/Code/downloadsmenu.py index 508ba26..5f0a9c6 100644 --- a/Contents/Code/downloadsmenu.py +++ b/Contents/Code/downloadsmenu.py @@ -15,7 +15,7 @@ ####################################################################################################### @route(PREFIX + '/AddToAutoPilotDownloads') -def AddToAutoPilotDownloads(title, year, type, purl=None, thumb=None, summary=None, quality=None, file_size=None, riptype='BRRIP', season=None, season_end=None, episode_start=None, episode_end=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, all_seasons=False, edit=False, mode=None, sub_mand=False, scheduled=False, smart_add=False, ssources=None, sproviders=None, **kwargs): +def AddToAutoPilotDownloads(title, year, type, purl=None, thumb=None, summary=None, quality=None, file_size=None, riptype='BRRIP', season=None, season_end=None, episode_start=None, episode_end=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, all_seasons=False, edit=False, mode=None, sub_mand=False, scheduled=False, smart_add=False, ssources=None, sproviders=None, imdbid=None, xitem=None, **kwargs): try: admin = True if str(admin) == 'True' else False @@ -160,12 +160,12 @@ def AddToAutoPilotDownloads(title, year, type, purl=None, thumb=None, summary=No if retInAQ == True: oc = ObjectContainer(title1='Add New or Replace Existing AutoPilot Items ?', no_cache=common.isForceNoCache()) oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode='add', sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode='add', sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Add as New Items" ) ) oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode='replace', sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode='replace', sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Replace Existing Items" ) ) @@ -186,60 +186,68 @@ def AddToAutoPilotDownloads(title, year, type, purl=None, thumb=None, summary=No # return oc #return main.MyMessage(title='Return', msg='Item exists. Use back to Return to previous screen') - if (quality == None and file_size == None) or (ret == True and edit == False): + if (quality == None and file_size == None or 'NotDefined' in str(file_size)) or (ret == True and edit == False): if ret == True: oc = ObjectContainer(title1='Update Quality or FileSize', no_cache=common.isForceNoCache()) else: oc = ObjectContainer(title1='Select Quality or FileSize', no_cache=common.isForceNoCache()) oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size='%s:%s'%(0,100*common.TO_GB), riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size='%s:%s'%(0,100*common.TO_GB), riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Enabled: %s | File-Size: %s" % (common.GetEmoji(type=True if file_size=='%s:%s'%(0,100*common.TO_GB) else False, mode='simple', session=session), 'Largest Available File') ) ) for item in common.INTERNAL_SOURCES_SIZES: if item['enabled']: oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size='%s:%s'%(item['LL'],item['UL']), riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size='%s:%s'%(item['LL'],item['UL']), riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Enabled: %s | File-Size: %s" % (common.GetEmoji(type=True if file_size=='%s:%s'%(item['LL'],item['UL']) else False, mode='simple', session=session), item['label']) ) ) + if file_size == None: + dktitle = "Enabled: %s | Custom File-Size: %s (Define Min. in MB)" % (common.GetEmoji(type=False, mode='txt', session=session), file_size) + elif 'NotDefined' in file_size: + dktitle = "Enabled: %s | Custom File-Size: %sGB (Define Max. in MB)" % (common.GetEmoji(type=True, mode='txt', session=session), file_size.split(':')[0]) + elif file_size != None: + dktitle = "Enabled: %s | Custom File-Size: %sGB >= %sGB" % (common.GetEmoji(type=True, mode='txt', session=session), file_size.split(':')[0], file_size.split(':')[1]) + dktitle = unicode(dktitle) + DumbKeyboard(PREFIX, oc, AddToAutoPilotDownloadsInputMinMaxSize, dktitle=dktitle, dkthumb=common.GetThumb(R(common.ICON_DK_ENABLE), session=session), dkNumOnly=True, dkHistory=False, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem) for item in common.INTERNAL_SOURCES_QUALS: if item['enabled']: oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=item['label'], file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=item['label'], file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Enabled: %s | Quality: %s" % (common.GetEmoji(type=True if quality==item['label'] else False, mode='simple', session=session), item['label']) ) ) for item in common.INTERNAL_SOURCES_RIPTYPE: if 'BRRIP' in item['label']: oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=item['label'], season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=item['label'], season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Enabled: %s | Rip-Type: %s" % (common.GetEmoji(type=True if riptype==item['label'] else False, mode='simple', session=session), item['label']) ) ) oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=not sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=not sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Prefer Source with Subtitle: %s" % common.GetEmoji(type=sub_mand, mode='simple', session=session) ) ) oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=not scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=not scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Run Later via Scheduler: %s" % common.GetEmoji(type=scheduled, mode='simple', session=session) ) ) if type == 'show': oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=not smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=not smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Smart Add for To Be Aired Episodes: %s" % common.GetEmoji(type=smart_add, mode='simple', session=session) ) ) oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Sources: %s >>" % ('All' if ssources==None else common.getSelectedItems(ssources)) ) ) oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), title = "Providers: %s >>" % ('All' if sproviders==None else common.getSelectedItems(sproviders)) ) ) @@ -259,7 +267,7 @@ def AddToAutoPilotDownloads(title, year, type, purl=None, thumb=None, summary=No for item in common.DOWNLOAD_OPTIONS[type]: if item['enabled']: oc.add(DirectoryObject( - key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=item['path'], section_title=item['title'], section_key=item['key'], session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders), + key = Callback(AddToAutoPilotDownloads, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=item['path'], section_title=item['title'], section_key=item['key'], session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem), thumb = common.GetThumb(R(common.ICON_SAVE), session=session), title = '%s | %s' % (item['title'], item['path']) ) @@ -268,8 +276,8 @@ def AddToAutoPilotDownloads(title, year, type, purl=None, thumb=None, summary=No return MC.message_container('Download Sources', 'No Download Location set under Download Options') else: if type == 'show': - DumbKeyboard(PREFIX, oc, AddToAutoPilotDownloadsInputEp, dktitle = 'Ep. Start Index:%s' % episode_start, dkthumb=common.GetThumb(R(common.ICON_DK_ENABLE), session=session), dkNumOnly=True, dkHistory=False, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, ep_id='start', edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders) - DumbKeyboard(PREFIX, oc, AddToAutoPilotDownloadsInputEp, dktitle = 'Ep. End Index:%s' % episode_end, dkthumb=common.GetThumb(R(common.ICON_DK_ENABLE), session=session), dkNumOnly=True, dkHistory=False, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, ep_id='end', edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders) + DumbKeyboard(PREFIX, oc, AddToAutoPilotDownloadsInputEp, dktitle = 'Ep. Start Index:%s' % episode_start, dkthumb=common.GetThumb(R(common.ICON_DK_ENABLE), session=session), dkNumOnly=True, dkHistory=False, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, ep_id='start', edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem) + DumbKeyboard(PREFIX, oc, AddToAutoPilotDownloadsInputEp, dktitle = 'Ep. End Index:%s' % episode_end, dkthumb=common.GetThumb(R(common.ICON_DK_ENABLE), session=session), dkNumOnly=True, dkHistory=False, title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, ep_id='end', edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem) oc.add(DirectoryObject(key = Callback(Downloads, title="Downloads", session = session), title = "<< Downloads", thumb = common.GetThumb(R(common.ICON_DOWNLOADS), session=session))) oc.add(DirectoryObject(key = Callback(main.MainMenu), title = '<< Main Menu', thumb = common.GetThumb(R(common.ICON), session=session))) return oc @@ -284,9 +292,9 @@ def AddToAutoPilotDownloads(title, year, type, purl=None, thumb=None, summary=No season_end = season if type == 'show': - item = {'title':title, 'year':year, 'season':season, 'season_end':season_end, 'episode':int(episode_start), 'thumb':thumb, 'summary':summary, 'episode_start':int(episode_start), 'episode_end':int(episode_end), 'quality':quality, 'file_size':file_size, 'riptype':riptype, 'vidtype':vidtype, 'section_path':section_path, 'section_title':section_title, 'section_key':section_key, 'admin':admin, 'timeAdded':time.time(), 'first_time':time.time(), 'type':type, 'session':session, 'purl':purl, 'status':common.DOWNLOAD_AUTOPILOT_STATUS[3], 'fsBytes':0, 'uid':uid, 'all_seasons':all_seasons, 'sub_mand':sub_mand, 'scheduled':scheduled, 'smart_add':smart_add, 'smart_add_active':False, 'ssources':ssources, 'sproviders':sproviders} + item = {'title':title, 'year':year, 'season':season, 'season_end':season_end, 'episode':int(episode_start), 'thumb':thumb, 'summary':summary, 'episode_start':int(episode_start), 'episode_end':int(episode_end), 'quality':quality, 'file_size':file_size, 'riptype':riptype, 'vidtype':vidtype, 'section_path':section_path, 'section_title':section_title, 'section_key':section_key, 'admin':admin, 'timeAdded':time.time(), 'first_time':time.time(), 'type':type, 'session':session, 'purl':purl, 'status':common.DOWNLOAD_AUTOPILOT_STATUS[3], 'fsBytes':0, 'uid':uid, 'all_seasons':all_seasons, 'sub_mand':sub_mand, 'scheduled':scheduled, 'smart_add':smart_add, 'smart_add_active':False, 'ssources':ssources, 'sproviders':sproviders, 'imdbid':imdbid, 'xitem':xitem} else: - item = {'title':title, 'year':year, 'season':season, 'season_end':season_end, 'episode':episode_start, 'thumb':thumb, 'summary':summary, 'quality':quality, 'file_size':file_size, 'riptype':riptype, 'vidtype':vidtype, 'section_path':section_path, 'section_title':section_title, 'section_key':section_key, 'admin':admin, 'timeAdded':time.time(), 'first_time':time.time(), 'type':type, 'session':session, 'purl':purl, 'status':common.DOWNLOAD_AUTOPILOT_STATUS[3], 'fsBytes':0, 'uid':uid, 'all_seasons':all_seasons, 'sub_mand':sub_mand, 'scheduled':scheduled, 'smart_add':smart_add, 'smart_add_active':False, 'ssources':ssources, 'sproviders':sproviders} + item = {'title':title, 'year':year, 'season':season, 'season_end':season_end, 'episode':episode_start, 'thumb':thumb, 'summary':summary, 'quality':quality, 'file_size':file_size, 'riptype':riptype, 'vidtype':vidtype, 'section_path':section_path, 'section_title':section_title, 'section_key':section_key, 'admin':admin, 'timeAdded':time.time(), 'first_time':time.time(), 'type':type, 'session':session, 'purl':purl, 'status':common.DOWNLOAD_AUTOPILOT_STATUS[3], 'fsBytes':0, 'uid':uid, 'all_seasons':all_seasons, 'sub_mand':sub_mand, 'scheduled':scheduled, 'smart_add':smart_add, 'smart_add_active':False, 'ssources':ssources, 'sproviders':sproviders, 'imdbid':imdbid, 'xitem':xitem} if mode == 'replace': save_bool = False @@ -329,7 +337,7 @@ def AddToAutoPilotDownloads(title, year, type, purl=None, thumb=None, summary=No #################################################################################################### @route(PREFIX + "/AddToAutoPilotDownloadsInputEp") -def AddToAutoPilotDownloadsInputEp(query, title, year, type, purl=None, thumb=None, summary=None, quality=None, file_size=None, riptype='BRRIP', season=None, season_end=None, episode_start=None, episode_end=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, all_seasons=False, ep_id='start', edit=False, mode=None, sub_mand=False, scheduled=False, smart_add=False, ssources=None, sproviders=None, **kwargs): +def AddToAutoPilotDownloadsInputEp(query, title, year, type, purl=None, thumb=None, summary=None, quality=None, file_size=None, riptype='BRRIP', season=None, season_end=None, episode_start=None, episode_end=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, all_seasons=False, ep_id='start', edit=False, mode=None, sub_mand=False, scheduled=False, smart_add=False, ssources=None, sproviders=None, imdbid=None, xitem=None, **kwargs): if ep_id == 'start': try: @@ -342,7 +350,28 @@ def AddToAutoPilotDownloadsInputEp(query, title, year, type, purl=None, thumb=No except: episode_end = '1' - return AddToAutoPilotDownloads(title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders) + return AddToAutoPilotDownloads(title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem) + +#################################################################################################### +@route(PREFIX + "/AddToAutoPilotDownloadsInputMinMaxSize") +def AddToAutoPilotDownloadsInputMinMaxSize(query, title, year, type, purl=None, thumb=None, summary=None, quality=None, file_size=None, riptype='BRRIP', season=None, season_end=None, episode_start=None, episode_end=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, all_seasons=False, edit=False, mode=None, sub_mand=False, scheduled=False, smart_add=False, ssources=None, sproviders=None, imdbid=None, xitem=None, **kwargs): + + if file_size == None: + try: + file_size = '%s:NotDefined' % str(round((float(query)/1024.0), 2)) + except: + file_size = '0:NotDefined' + else: + try: + f1 = float(file_size.split(':')[0]) + f2 = round((float(query)/1024.0), 2) + if f1 > f2: + f2 = f1 + 0.5 + file_size = '%s:%s' % (f1,f2) + except: + file_size = file_size.replace('NotDefined',str(100*common.TO_GB)) + + return AddToAutoPilotDownloads(title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, quality=quality, file_size=file_size, riptype=riptype, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, all_seasons=all_seasons, edit=edit, mode=mode, sub_mand=sub_mand, scheduled=scheduled, smart_add=smart_add, ssources=ssources, sproviders=sproviders, imdbid=imdbid, xitem=xitem) ####################################################################################################### def AutoPilotDownloadThread(item): @@ -514,8 +543,13 @@ def AutoPilotDownloadCall(item=None, uid=None, session=None): section_key = i['section_key'] provider = i['provider'] source = i['source'] + imdbid = None + try: + imdbid = i['imdbid'] + except: + pass - return AddToAutoPilotDownloads(title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=True, edit=True, mode='add') + return AddToAutoPilotDownloads(title=title, year=year, type=type, purl=purl, thumb=thumb, summary=summary, season=season, season_end=season_end, episode_start=episode_start, episode_end=episode_end, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=True, edit=True, mode='add', imdbid=imdbid, xitem=xitem) except Exception as e: err = '%s' % e @@ -852,14 +886,14 @@ def AutoPilotDownloadThread2(item, sources): def AutoPilotDownloadThread3(item, s, fsBytes, fs): try: - AddToDownloadsList(title=item['short_title'] if item['type']=='show' else item['title'], purl=item['purl'], url=s['url'], durl=s['durl'], summary=item['summary'], thumb=item['thumb'], year=item['year'], quality=s['quality'], source=s['source'], source_meta={}, file_meta={}, type=item['type'], vidtype=item['vidtype'], resumable=s['resumeDownload'], sub_url=s['sub_url'], fsBytes=fsBytes, fs=fs, file_ext=s['file_ext'], mode=common.DOWNLOAD_MODE[0], section_path=item['section_path'], section_title=item['section_title'], section_key=item['section_key'], session=item['session'], admin=item['admin'], params=s['params'], riptype=s['rip'], season=item['season'], episode=item['episode'], provider=s['provider'], page_url=s['page_url'], seq=s['seq']) + AddToDownloadsList(title=item['short_title'] if item['type']=='show' else item['title'], purl=item['purl'], url=s['url'], durl=s['durl'], summary=item['summary'], thumb=item['thumb'], year=item['year'], quality=s['quality'], source=s['source'], source_meta={}, file_meta={}, type=item['type'], vidtype=item['vidtype'], resumable=s['resumeDownload'], sub_url=s['sub_url'], fsBytes=fsBytes, fs=fs, file_ext=s['file_ext'], mode=common.DOWNLOAD_MODE[0], section_path=item['section_path'], section_title=item['section_title'], section_key=item['section_key'], session=item['session'], admin=item['admin'], params=s['params'], riptype=s['rip'], season=item['season'], episode=item['episode'], provider=s['provider'], page_url=s['page_url'], seq=s['seq'], imdbid=item['imdbid'], xitem=item['xitem']) except Exception as e: err = '{}'.format(e) Log('ERROR: downloadsmenu.py > AutoPilotDownloadThread3: %s' % err) ####################################################################################################### @route(PREFIX + '/AddToDownloadsListPre') -def AddToDownloadsListPre(title, year, url, durl, purl, summary, thumb, quality, source, type, resumable, source_meta, file_meta, mode, sub_url=None, fsBytes=None, fs=None, file_ext=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, update=False, params=None, riptype=None, season=None, episode=None, provider=None, page_url=None, seq=0, force_add=False, uid_upd=None, **kwargs): +def AddToDownloadsListPre(title, year, url, durl, purl, summary, thumb, quality, source, type, resumable, source_meta, file_meta, mode, sub_url=None, fsBytes=None, fs=None, file_ext=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, update=False, params=None, riptype=None, season=None, episode=None, provider=None, page_url=None, seq=0, force_add=False, uid_upd=None, imdbid=None, xitem=None, **kwargs): try: admin = True if str(admin) == 'True' else False @@ -992,9 +1026,9 @@ def AddToDownloadsListPre(title, year, url, durl, purl, summary, thumb, quality, t_exists = 'Item in Completed Downloads %s | %s' % (EncTxt_t['section_path'],timestr_t) oc.add(DirectoryObject(title = '<< %s >>' % t_exists, key = Callback(main.MyMessage, title='Item Exists', msg=t_exists))) else: - oc.add(DirectoryObject(key = Callback(AddToDownloadsListPre, title=title, purl=purl, url=url, durl=durl, summary=summary, thumb=thumb, year=year, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, resumable=resumable, sub_url=sub_url, fsBytes=fsBytes, fs=fs, file_ext=file_ext, mode=mode, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, update=True, params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, uid_upd=u_i), title = 'Update item. %s | %s | %s' % (EncTxt_t['section_path'],EncTxt_t['fid'],timestr_t))) + oc.add(DirectoryObject(key = Callback(AddToDownloadsListPre, title=title, purl=purl, url=url, durl=durl, summary=summary, thumb=thumb, year=year, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, resumable=resumable, sub_url=sub_url, fsBytes=fsBytes, fs=fs, file_ext=file_ext, mode=mode, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, update=True, params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, uid_upd=u_i, imdbid=imdbid, xitem=xitem), title = 'Update item. %s | %s | %s' % (EncTxt_t['section_path'],EncTxt_t['fid'],timestr_t))) - oc.add(DirectoryObject(key = Callback(AddToDownloadsListPre, title=title, purl=purl, url=url, durl=durl, summary=summary, thumb=thumb, year=year, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, resumable=resumable, sub_url=sub_url, fsBytes=fsBytes, fs=fs, file_ext=file_ext, mode=mode, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, update=False, params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, force_add=True), title = 'Add as New < Item will be duplicated >')) + oc.add(DirectoryObject(key = Callback(AddToDownloadsListPre, title=title, purl=purl, url=url, durl=durl, summary=summary, thumb=thumb, year=year, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, resumable=resumable, sub_url=sub_url, fsBytes=fsBytes, fs=fs, file_ext=file_ext, mode=mode, vidtype=vidtype, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, update=False, params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, imdbid=imdbid, xitem=xitem, force_add=True), title = 'Add as New < Item will be duplicated >')) oc.add(DirectoryObject(key = Callback(Downloads, title=" Downloads", session = session), title = "<< Downloads")) oc.add(DirectoryObject(key = Callback(main.MainMenu), title = '<< Main Menu')) return oc @@ -1019,7 +1053,7 @@ def AddToDownloadsListPre(title, year, url, durl, purl, summary, thumb, quality, chunk_size = int(1024.0 * 1024.0 * float(common.DOWNLOAD_CHUNK_SIZE)) # in bytes fid = '.'+common.id_generator() - EncTxt = E(JSON.StringFromObject({'title':title, 'year':year, 'url':url, 'durl':durl, 'purl':purl, 'sub_url':sub_url, 'summary':summary, 'thumb':thumb, 'fsBytes':int(fsBytes), 'fs':fs, 'chunk_size':chunk_size, 'file_ext':file_ext, 'quality':quality, 'source':source, 'source_meta':source_meta, 'file_meta':file_meta, 'uid':uid, 'fid':fid, 'type':type, 'vidtype':vidtype, 'resumable':resumable, 'status':common.DOWNLOAD_STATUS[4], 'startPos':0, 'timeAdded':time.time(), 'first_time':time.time(), 'progress':0, 'chunk_speed':0,'avg_speed':0,'avg_speed_curr':0, 'eta':0, 'error':'', 'last_error':'Unknown Error', 'action':common.DOWNLOAD_PROPS[3],'section_path':section_path, 'section_title':section_title, 'section_key':section_key, 'user':user, 'provider':provider})) + EncTxt = E(JSON.StringFromObject({'title':title, 'year':year, 'url':url, 'durl':durl, 'purl':purl, 'sub_url':sub_url, 'summary':summary, 'thumb':thumb, 'fsBytes':int(fsBytes), 'fs':fs, 'chunk_size':chunk_size, 'file_ext':file_ext, 'quality':quality, 'source':source, 'source_meta':source_meta, 'file_meta':file_meta, 'uid':uid, 'fid':fid, 'type':type, 'vidtype':vidtype, 'resumable':resumable, 'status':common.DOWNLOAD_STATUS[4], 'startPos':0, 'timeAdded':time.time(), 'first_time':time.time(), 'progress':0, 'chunk_speed':0,'avg_speed':0,'avg_speed_curr':0, 'eta':0, 'error':'', 'last_error':'Unknown Error', 'action':common.DOWNLOAD_PROPS[3],'section_path':section_path, 'section_title':section_title, 'section_key':section_key, 'user':user, 'provider':provider, 'imdbid':imdbid, 'xitem':xitem})) Dict[uid] = EncTxt Dict.Save() return MC.message_container('Requested Sources', 'Successfully added to Requested List') @@ -1034,7 +1068,7 @@ def AddToDownloadsListPre(title, year, url, durl, purl, summary, thumb, quality, Dict['DOWNLOAD_OPTIONS_SECTION_TEMP'][tuec][x] = common.DOWNLOAD_OPTIONS[x] Dict.Save() - return AddToDownloadsList(title=title, purl=purl, url=url, durl=durl, summary=summary, thumb=thumb, year=year, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, vidtype=vidtype, resumable=resumable, sub_url=sub_url, fsBytes=fsBytes, fs=fs, file_ext=file_ext, mode=mode, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, update=update, user=user,params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, force_add=force_add) + return AddToDownloadsList(title=title, purl=purl, url=url, durl=durl, summary=summary, thumb=thumb, year=year, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, vidtype=vidtype, resumable=resumable, sub_url=sub_url, fsBytes=fsBytes, fs=fs, file_ext=file_ext, mode=mode, section_path=section_path, section_title=section_title, section_key=section_key, session=session, admin=admin, update=update, user=user,params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, force_add=force_add, imdbid=imdbid, xitem=xitem) except Exception as e: err = '{}'.format(e) Log('Error AddToDownloadsListPre: %s' % err) @@ -1043,7 +1077,7 @@ def AddToDownloadsListPre(title, year, url, durl, purl, summary, thumb, quality, ###################################################################################### # Adds a movie to the DownloadsList list using the (title + 'Down5Split') as a key for the url @route(PREFIX + "/addToDownloadsList") -def AddToDownloadsList(title, year, url, durl, purl, summary, thumb, quality, source, type, resumable, source_meta, file_meta, sub_url=None, fsBytes=None, fs=None, file_ext=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, update=False, user=None, params=None, riptype=None, season=None, episode=None, provider=None, page_url=None, seq=0, force_add=False, **kwargs): +def AddToDownloadsList(title, year, url, durl, purl, summary, thumb, quality, source, type, resumable, source_meta, file_meta, sub_url=None, fsBytes=None, fs=None, file_ext=None, vidtype=None, section_path=None, section_title=None, section_key=None, session=None, admin=False, update=False, user=None, params=None, riptype=None, season=None, episode=None, provider=None, page_url=None, seq=0, force_add=False, imdbid=None, xitem=None, **kwargs): admin = True if str(admin) == 'True' else False update = True if str(update) == 'True' else False @@ -1089,13 +1123,13 @@ def AddToDownloadsList(title, year, url, durl, purl, summary, thumb, quality, so LOCS.append(item) if len(LOCS) == 1: item = LOCS[0] - return AddToDownloadsList(title=title, year=year, url=url, durl=durl, purl=purl, summary=summary, thumb=thumb, fs=fs, fsBytes=fsBytes, file_ext=file_ext, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, vidtype=vidtype, resumable=resumable, sub_url=sub_url, section_path=item['path'], section_title=item['title'], section_key=item['key'], session=session, admin=admin, update=update, user=user, params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, force_add=force_add) + return AddToDownloadsList(title=title, year=year, url=url, durl=durl, purl=purl, summary=summary, thumb=thumb, fs=fs, fsBytes=fsBytes, file_ext=file_ext, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, vidtype=vidtype, resumable=resumable, sub_url=sub_url, section_path=item['path'], section_title=item['title'], section_key=item['key'], session=session, admin=admin, update=update, user=user, params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, force_add=force_add, imdbid=imdbid, xitem=xitem) else: oc = ObjectContainer(title1='Select Location', no_cache=common.isForceNoCache()) for item in DOWNLOAD_OPTIONS_SECTION_TEMP[type]: if item['enabled']: oc.add(DirectoryObject( - key = Callback(AddToDownloadsList, title=title, year=year, url=url, durl=durl, purl=purl, summary=summary, thumb=thumb, fs=fs, fsBytes=fsBytes, file_ext=file_ext, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, vidtype=vidtype, resumable=resumable, sub_url=sub_url, section_path=item['path'], section_title=item['title'], section_key=item['key'], session=session, admin=admin, update=update, user=user, params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, force_add=force_add), + key = Callback(AddToDownloadsList, title=title, year=year, url=url, durl=durl, purl=purl, summary=summary, thumb=thumb, fs=fs, fsBytes=fsBytes, file_ext=file_ext, quality=quality, source=source, source_meta=source_meta, file_meta=file_meta, type=type, vidtype=vidtype, resumable=resumable, sub_url=sub_url, section_path=item['path'], section_title=item['title'], section_key=item['key'], session=session, admin=admin, update=update, user=user, params=params, riptype=riptype, season=season, episode=episode, provider=provider, page_url=page_url, seq=seq, force_add=force_add, imdbid=imdbid, xitem=xitem), title = '%s | %s' % (item['title'], item['path']) ) ) @@ -1163,7 +1197,7 @@ def AddToDownloadsList(title, year, url, durl, purl, summary, thumb, quality, so else: watch_title = title - EncTxt = E(JSON.StringFromObject({'title':title, 'watch_title':watch_title, 'year':year, 'season':season, 'episode':episode, 'url':url, 'durl':durl, 'purl':purl, 'sub_url':sub_url, 'summary':summary, 'thumb':thumb, 'fsBytes':int(fsBytes), 'fs':fs, 'chunk_size':chunk_size, 'file_ext':file_ext, 'quality':quality, 'source':source, 'source_meta':source_meta, 'file_meta':file_meta, 'uid':uid, 'fid':fid, 'type':type, 'vidtype':vidtype, 'resumable':resumable, 'status':common.DOWNLOAD_STATUS[0], 'startPos':0, 'timeAdded':time.time(), 'first_time':time.time(), 'progress':0, 'chunk_speed':0,'avg_speed':0,'avg_speed_curr':0, 'eta':0, 'error':'', 'last_error':'Unknown Error', 'action':common.DOWNLOAD_ACTIONS[4],'section_path':section_path, 'section_title':section_title, 'section_key':section_key, 'user':user, 'params':params, 'riptype':riptype, 'provider':provider, 'page_url':page_url, 'seq':int(seq)})) + EncTxt = E(JSON.StringFromObject({'title':title, 'watch_title':watch_title, 'year':year, 'season':season, 'episode':episode, 'url':url, 'durl':durl, 'purl':purl, 'sub_url':sub_url, 'summary':summary, 'thumb':thumb, 'fsBytes':int(fsBytes), 'fs':fs, 'chunk_size':chunk_size, 'file_ext':file_ext, 'quality':quality, 'source':source, 'source_meta':source_meta, 'file_meta':file_meta, 'uid':uid, 'fid':fid, 'type':type, 'vidtype':vidtype, 'resumable':resumable, 'status':common.DOWNLOAD_STATUS[0], 'startPos':0, 'timeAdded':time.time(), 'first_time':time.time(), 'progress':0, 'chunk_speed':0,'avg_speed':0,'avg_speed_curr':0, 'eta':0, 'error':'', 'last_error':'Unknown Error', 'action':common.DOWNLOAD_ACTIONS[4],'section_path':section_path, 'section_title':section_title, 'section_key':section_key, 'user':user, 'params':params, 'riptype':riptype, 'provider':provider, 'page_url':page_url, 'seq':int(seq), 'imdbid':imdbid, 'xitem':xitem})) Dict[uid] = EncTxt Dict.Save() @@ -1596,6 +1630,15 @@ def DownloadingFilesMenu(title, uid, choice=None, session=None, status=None, con key = Callback(AutoPilotDownloadThreadCall, item=E(JSON.StringFromObject(i))) ) ) + try: + if common.DEV_DEBUG == True and Prefs["use_debug"]: + Log(i) + t1=i['imdbid'] + t2=i['xitem'] + if t1==None or t2==None: + raise Exception() + except: + urldata = None if i['purl'] != None: oc.add(DirectoryObject( title = 'Video Page', @@ -1604,6 +1647,23 @@ def DownloadingFilesMenu(title, uid, choice=None, session=None, status=None, con thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) + elif urldata != None: + if type == 'movie': + oc.add(DirectoryObject( + key = Callback(main.SearchExt, query=None, query2=i['short_title'], xtitle=i['watch_title'], xyear=i['year'], xtype=i['type'], ximdbid=i['imdbid'], xsummary=i['summary'], xthumb=i['thumb'], xitem=i['xitem'], session=session), + title = 'Video Page', + summary = 'Video Page: %s' % i['watch_title'], + thumb = common.GetThumb(R(common.ICON_ENTER), session=session) + ) + ) + else: + oc.add(DirectoryObject( + key = Callback(main.DoIMDBExtSources, title=i['watch_title'], year=i['year'], type=i['type'], imdbid=i['imdbid'], summary=i['summary'], thumb=i['thumb'], session=session), + title = 'Video Page', + summary = 'Video Page: %s' % i['watch_title'], + thumb = common.GetThumb(R(common.ICON_ENTER), session=session) + ) + ) else: oc.add(DirectoryObject( title = 'Video Page (Unavailable)', @@ -1698,6 +1758,15 @@ def DownloadingFilesMenu(title, uid, choice=None, session=None, status=None, con thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) + try: + if common.DEV_DEBUG == True and Prefs["use_debug"]: + Log(longstringObjs) + t1=longstringObjs['imdbid'] + t2=longstringObjs['xitem'] + if t1==None or t2==None: + raise Exception() + except: + urldata = None if longstringObjs['purl'] != None: oc.add(DirectoryObject( title = 'Video Page (Other Download Sources)', @@ -1706,6 +1775,23 @@ def DownloadingFilesMenu(title, uid, choice=None, session=None, status=None, con thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) + elif urldata != None: + if longstringObjs['type'] == 'movie': + oc.add(DirectoryObject( + key = Callback(main.SearchExt, query=None, query2=longstringObjs['short_title'], xtitle=longstringObjs['watch_title'], xyear=longstringObjs['year'], xtype=longstringObjs['type'], ximdbid=longstringObjs['imdbid'], xsummary=longstringObjs['summary'], xthumb=longstringObjs['thumb'], xitem=longstringObjs['xitem'], session=session), + title = 'Video Page', + summary = 'Video Page: %s' % longstringObjs['watch_title'], + thumb = common.GetThumb(R(common.ICON_ENTER), session=session) + ) + ) + else: + oc.add(DirectoryObject( + key = Callback(main.DoIMDBExtSources, title=longstringObjs['watch_title'], year=longstringObjs['year'], type=longstringObjs['type'], imdbid=longstringObjs['imdbid'], summary=longstringObjs['summary'], thumb=longstringObjs['thumb'], session=session), + title = 'Video Page', + summary = 'Video Page: %s' % longstringObjs['watch_title'], + thumb = common.GetThumb(R(common.ICON_ENTER), session=session) + ) + ) else: oc.add(DirectoryObject( title = 'Video Page (Unavailable)', diff --git a/Contents/Code/main.py b/Contents/Code/main.py index b417e08..f877fa1 100644 --- a/Contents/Code/main.py +++ b/Contents/Code/main.py @@ -2269,7 +2269,7 @@ def GetInput(query, title, key, urlpath, page_count, session, method, is9anime=' ###################################################################################### @route(PREFIX + "/episodedetail") -def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, **kwargs): +def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, year=None, **kwargs): page_data, error = common.GetPageElements(url=url) if error != '': @@ -2360,6 +2360,9 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** try: year = str(page_data.xpath(".//*[@id='info']//dl[@class='meta col-sm-12'][2]//dd[2]//text()")[0][0:4]) except: + pass + + if year == None: year = 'Not Available' try: @@ -3531,7 +3534,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** )) if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=common.cleantitle.removeParanthesisAndSeason(title, SeasonN), thumb=thumb, summary=summary, purl=url, season=SeasonN, episode_start=1, episode_end=c, year=year, type='show', vidtype='show', session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=common.cleantitle.removeParanthesisAndSeason(title, SeasonN), thumb=thumb, summary=summary, purl=url, season=SeasonN, episode_start=1, episode_end=c, year=year, type='show', vidtype='show', session=session, admin=True, imdbid=imdb_id), title = 'Add to AutoPilot Queue', summary = 'Add to the AutoPilot Queue for Downloading', art = art, @@ -3593,7 +3596,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** )) if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=common.cleantitle.removeParanthesisAndSeason(title, SeasonN), thumb=thumb, summary=summary, purl=url, season=SeasonN, episode_start=1, episode_end=c, year=year, type='show', vidtype='show', session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=common.cleantitle.removeParanthesisAndSeason(title, SeasonN), thumb=thumb, summary=summary, purl=url, season=SeasonN, episode_start=1, episode_end=c, year=year, type='show', vidtype='show', session=session, admin=True, imdbid=imdb_id), title = 'Add to AutoPilot Queue', summary = 'Add to the AutoPilot Queue for Downloading', art = art, @@ -3656,7 +3659,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** ) ) oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=title, year=year, type='movie', vidtype='movie', summary=summary, thumb=thumb, purl=url, session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=title, year=year, type='movie', vidtype='movie', summary=summary, thumb=thumb, purl=url, session=session, admin=True, imdbid=imdb_id), title = 'Add to AutoPilot Queue', summary = 'Add to the AutoPilot Queue for Downloading', art = art, @@ -3857,7 +3860,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** ) ) oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=title, year=year, type='movie', vidtype='movie', summary=summary, thumb=thumb, purl=url, session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=title, year=year, type='movie', vidtype='movie', summary=summary, thumb=thumb, purl=url, session=session, admin=True, imdbid=imdb_id), title = 'Add to AutoPilot Queue', summary = 'Add to the AutoPilot Queue for Downloading', art = art, @@ -4248,7 +4251,7 @@ def VideoDetail(title, url, url_s, label_i_qual, label, serverts, thumb, summary qualx = vvv['qual'] if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToDownloadsListPre, title=title if tvshowtitle==None else tvshowtitlecleaned, season=season, episode=episode, purl=url, url=vv, durl=vv, summary=summary, thumb=thumb, year=year, quality=qualx, source=host, type=libtype, vidtype=libtype.lower(), resumable=True, source_meta={}, file_meta={}, sub_url=sub_url, mode=common.DOWNLOAD_MODE[0], session=session, admin=True, provider='Plugin', seq=seq_no), + key = Callback(downloadsmenu.AddToDownloadsListPre, title=title if tvshowtitle==None else tvshowtitlecleaned, season=season, episode=episode, purl=url, url=vv, durl=vv, summary=summary, thumb=thumb, year=year, quality=qualx, source=host, type=libtype, vidtype=libtype.lower(), resumable=True, source_meta={}, file_meta={}, sub_url=sub_url, mode=common.DOWNLOAD_MODE[0], session=session, admin=True, provider='Plugin', seq=seq_no, imdbid=None), title = '%s | Add to Download Queue' % qualx, summary = 'Adds the current video to Download List', art = art, @@ -4257,7 +4260,7 @@ def VideoDetail(title, url, url_s, label_i_qual, label, serverts, thumb, summary ) elif Prefs['disable_downloader'] == False: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToDownloadsListPre, title=title if tvshowtitle==None else tvshowtitlecleaned, season=season, episode=episode, purl=url, url=vv, durl=vv, summary=summary, thumb=thumb, year=year, quality=qualx, source=host, type=libtype, vidtype=libtype.lower(), resumable=True, source_meta={}, file_meta={}, sub_url=sub_url, mode=common.DOWNLOAD_MODE[1], session=session, admin=False, provider='Plugin', seq=seq_no), + key = Callback(downloadsmenu.AddToDownloadsListPre, title=title if tvshowtitle==None else tvshowtitlecleaned, season=season, episode=episode, purl=url, url=vv, durl=vv, summary=summary, thumb=thumb, year=year, quality=qualx, source=host, type=libtype, vidtype=libtype.lower(), resumable=True, source_meta={}, file_meta={}, sub_url=sub_url, mode=common.DOWNLOAD_MODE[1], session=session, admin=False, provider='Plugin', seq=seq_no, imdbid=None), title = '%s | Add to Request Queue' % qualx, summary = 'Adds the current video to Request List', art = art, @@ -4284,7 +4287,7 @@ def VideoDetail(title, url, url_s, label_i_qual, label, serverts, thumb, summary ftype = file['type'] if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToDownloadsListPre, title=title if tvshowtitle==None else tvshowtitlecleaned, season=season, episode=episode, purl=url, url=furl, durl=furl, summary=summary, thumb=thumb, year=year, quality=res, source=host_source, type=libtype, vidtype=libtype.lower(), resumable=True, source_meta={}, file_meta={}, sub_url=sub_url, mode=common.DOWNLOAD_MODE[0], session=session, admin=True, provider='Plugin', seq=seq_no), + key = Callback(downloadsmenu.AddToDownloadsListPre, title=title if tvshowtitle==None else tvshowtitlecleaned, season=season, episode=episode, purl=url, url=furl, durl=furl, summary=summary, thumb=thumb, year=year, quality=res, source=host_source, type=libtype, vidtype=libtype.lower(), resumable=True, source_meta={}, file_meta={}, sub_url=sub_url, mode=common.DOWNLOAD_MODE[0], session=session, admin=True, provider='Plugin', seq=seq_no, imdbid=None), title = '%s | Add to Download Queue' % res, summary = 'Adds the current video to Download List', art = art, @@ -4293,7 +4296,7 @@ def VideoDetail(title, url, url_s, label_i_qual, label, serverts, thumb, summary ) elif Prefs['disable_downloader'] == False: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToDownloadsListPre, title=title if tvshowtitle==None else tvshowtitlecleaned, season=season, episode=episode, purl=url, url=furl, durl=furl, summary=summary, thumb=thumb, year=year, quality=res, source=host_source, type=libtype, vidtype=libtype.lower(), resumable=True, source_meta={}, file_meta={}, sub_url=sub_url, mode=common.DOWNLOAD_MODE[1], session=session, admin=False, provider='Plugin', seq=seq_no), + key = Callback(downloadsmenu.AddToDownloadsListPre, title=title if tvshowtitle==None else tvshowtitlecleaned, season=season, episode=episode, purl=url, url=furl, durl=furl, summary=summary, thumb=thumb, year=year, quality=res, source=host_source, type=libtype, vidtype=libtype.lower(), resumable=True, source_meta={}, file_meta={}, sub_url=sub_url, mode=common.DOWNLOAD_MODE[1], session=session, admin=False, provider='Plugin', seq=seq_no, imdbid=None), title = '%s | Add to Request Queue' % res, summary = 'Adds the current video to Request List', art = art, @@ -4791,7 +4794,7 @@ def ExtSourcesDownload(title, url, summary, thumb, art, rating, duration, genre, downloadTitle = movtitle oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToDownloadsListPre, title=downloadTitle, purl=url, url=source['url'], durl=source['durl'], sub_url=source['sub_url'], page_url=source['page_url'], summary=summary, thumb=thumb, year=year, fsBytes=fsBytes, fs=fs, file_ext=source['file_ext'], quality=source['quality'], source=source['source'], source_meta={}, file_meta={}, type=libtype, vidtype=vidtype, resumable=source['resumeDownload'], mode=mode, session=session, admin=True if mode==common.DOWNLOAD_MODE[0] else False, params=source['params'], riptype=source['rip'], season=season, episode=episode, provider=source['provider'], seq = source['seq']), + key = Callback(downloadsmenu.AddToDownloadsListPre, title=downloadTitle, purl=url, url=source['url'], durl=source['durl'], sub_url=source['sub_url'], page_url=source['page_url'], summary=summary, thumb=thumb, year=year, fsBytes=fsBytes, fs=fs, file_ext=source['file_ext'], quality=source['quality'], source=source['source'], source_meta={}, file_meta={}, type=libtype, vidtype=vidtype, resumable=source['resumeDownload'], mode=mode, session=session, admin=True if mode==common.DOWNLOAD_MODE[0] else False, params=source['params'], riptype=source['rip'], season=season, episode=episode, provider=source['provider'], seq = source['seq'], imdbid=imdb_id), title = title_msg, summary = 'Adds the current video to %s List' % 'Download' if mode==common.DOWNLOAD_MODE[0] else 'Request', art = art, @@ -5251,12 +5254,16 @@ def RecentWatchList(title, session=None, **kwargs): c=0 for each in newlist: - + year = None longstring = each['val'] longstringsplit = longstring.split('RR44SS') stitle = unicode(longstringsplit[0]) url = longstringsplit[1] summary = unicode(longstringsplit[2]) + try: + year = re.findall(r'year:(.*?)\n', summary.lower())[0].strip() + except: + pass thumb = longstringsplit[3] timestr = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(float(longstringsplit[4]))) @@ -5298,7 +5305,7 @@ def RecentWatchList(title, session=None, **kwargs): items_in_recent.append(url) oc.add(DirectoryObject( - key=Callback(EpisodeDetail, title=stitle, url=url, thumb=thumb, session = session), + key=Callback(EpisodeDetail, title=stitle, url=url, thumb=thumb, session=session, year=year), title= '%s%s' % (ES,stitle), thumb=thumb, tagline = timestr, @@ -5447,6 +5454,10 @@ def Bookmarks(title, session = None, **kwargs): stitle = unicode(longstring.split('Key5Split')[0]) url = longstring.split('Key5Split')[1] summary = unicode(longstring.split('Key5Split')[2]) + try: + year = re.findall(r'year:(.*?)\n', summary.lower())[0].strip() + except: + pass thumb = longstring.split('Key5Split')[3] type = 'movie' try: @@ -5527,7 +5538,7 @@ def Bookmarks(title, session = None, **kwargs): ) else: oc.add(DirectoryObject( - key=Callback(EpisodeDetail, title=stitle, url=url, thumb=thumb, session = session), + key=Callback(EpisodeDetail, title=stitle, url=url, thumb=thumb, session=session, year=year), title='%s%s' % (ES,stitle), tagline=stitle, thumb=thumb, @@ -6013,7 +6024,7 @@ def Search(query=None, surl=None, page_count='1', mode='default', thumb=None, su if no_elems > 0: if common.DOWNLOAD_ALL_SEASONS == True and Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=title_auto, thumb=thumb_auto, summary=summary_auto, purl=url, season=None, season_end=len(oc), episode_start=1, episode_end=None, year=None, type='show', vidtype='show', session=session, admin=True, all_seasons=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=title_auto, thumb=thumb_auto, summary=summary_auto, purl=url, season=None, season_end=len(oc), episode_start=1, episode_end=None, year=None, type='show', vidtype='show', session=session, admin=True, all_seasons=True, imdbid=None), title = 'Add to AutoPilot Queue', summary = 'Add to the AutoPilot Queue for Downloading', thumb = R(common.ICON_OTHERSOURCESDOWNLOAD_AUTO) @@ -6096,14 +6107,13 @@ def SearchExt(query=None, query2=None, session=None, xtitle=None, xyear=None, xt else: xitem = None - dobj = DirectoryObject( - key = Callback(DoIMDBExtSources, title=xtitle, year=xyear, type=xtype, imdbid=ximdbid, summary=xsummary, item=xitem, thumb=xthumb, session=session), - title = '%s (%s) - Sources' % (xtitle, xyear), - summary = xsummary, - thumb = common.GetThumb(R(common.ICON_OTHERSOURCES), session=session)) - oc.add(dobj) - if xtype == 'movie': + dobj = DirectoryObject( + key = Callback(DoIMDBExtSources, title=xtitle, year=xyear, type=xtype, imdbid=ximdbid, summary=xsummary, item=xitem, thumb=xthumb, session=session), + title = '%s (%s) - Sources' % (xtitle, xyear), + summary = xsummary, + thumb = common.GetThumb(R(common.ICON_OTHERSOURCES), session=session)) + oc.add(dobj) if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: dobj = DirectoryObject( key = Callback(DoIMDBExtSources, title=xtitle, year=xyear, type=xtype, imdbid=ximdbid, summary=xsummary, item=xitem, thumb=xthumb, session=session, extype='download'), @@ -6113,7 +6123,7 @@ def SearchExt(query=None, query2=None, session=None, xtitle=None, xyear=None, xt oc.add(dobj) dobj = DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=xtitle, year=xyear, type='movie', vidtype='movie', summary=xsummary, thumb=xthumb, purl=None, session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=xtitle, year=xyear, type='movie', vidtype='movie', summary=xsummary, thumb=xthumb, purl=None, session=session, admin=True, imdbid=ximdbid), title = '%s (%s) - Add to AutoPilot Queue' % (xtitle, xyear), summary = xsummary, thumb = common.GetThumb(R(common.ICON_OTHERSOURCESDOWNLOAD_AUTO), session=session)) @@ -6145,6 +6155,14 @@ def SearchExt(query=None, query2=None, session=None, xtitle=None, xyear=None, xt thumb = common.GetThumb(R(common.ICON_QUEUE), session=session) ) ) + else: + return DoIMDBExtSources(title=xtitle, year=xyear, type=xtype, imdbid=ximdbid, summary=xsummary, item=xitem, thumb=xthumb, session=session) + dobj = DirectoryObject( + key = Callback(DoIMDBExtSources, title=xtitle, year=xyear, type=xtype, imdbid=ximdbid, summary=xsummary, item=xitem, thumb=xthumb, session=session), + title = '%s (%s) - Sources' % (xtitle, xyear), + summary = xsummary, + thumb = common.GetThumb(R(common.ICON_OTHERSOURCES), session=session)) + oc.add(dobj) oc.add(DirectoryObject( key = Callback(MainMenu), @@ -6291,7 +6309,7 @@ def SearchExt(query=None, query2=None, session=None, xtitle=None, xyear=None, xt title = common.EMOJI_EXT+watch_title, summary = summary, thumb = xthumb) - else: + else: dobj = DirectoryObject( key = Callback(SearchExt, query=query, query2=query2, session=session, xtitle=title, xyear=year, xtype=type, ximdbid=imdbid, xsummary=summary, xthumb=xthumb, xitem=xitem, append='false', final='false'), title = common.EMOJI_EXT+watch_title, @@ -6368,9 +6386,9 @@ def DoIMDBExtSources(title, year, type, imdbid, season=None, episode=None, episo return ExtSources(movtitle=title, year=year, title=title, url=None, summary=summary, thumb=thumb, art=None, rating=rating, duration=duration, genre=genre, directors=directors, roles=roles, season=season, episode=episode, session=session) else: if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: - return ExtSourcesDownload(movtitle=title, year=year, title=title, url=None, summary=summary, thumb=thumb, art=None, rating=rating, duration=duration, genre=genre, directors=directors, roles=roles, season=season, episode=episode, session=session, mode=common.DOWNLOAD_MODE[0]) + return ExtSourcesDownload(movtitle=title, year=year, title=title, url=None, summary=summary, thumb=thumb, art=None, rating=rating, duration=duration, genre=genre, directors=directors, roles=roles, imdb_id=imdbid, season=season, episode=episode, session=session, mode=common.DOWNLOAD_MODE[0]) elif Prefs['disable_downloader'] == False: - return ExtSourcesDownload(movtitle=title, year=year, title=title, url=None, summary=summary, thumb=thumb, art=None, rating=rating, duration=duration, genre=genre, directors=directors, roles=roles, season=season, episode=episode, session=session, mode=common.DOWNLOAD_MODE[1]) + return ExtSourcesDownload(movtitle=title, year=year, title=title, url=None, summary=summary, thumb=thumb, art=None, rating=rating, duration=duration, genre=genre, directors=directors, roles=roles, imdb_id=imdbid, season=season, episode=episode, session=session, mode=common.DOWNLOAD_MODE[1]) else: if season != None: @@ -6399,7 +6417,7 @@ def DoIMDBExtSources(title, year, type, imdbid, season=None, episode=None, episo ) if common.DOWNLOAD_ALL_SEASONS == True and Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=title, thumb=thumb, summary=summary, purl=None, season=None, season_end=SeasonNR+1, episode_start=1, episode_end=None, year=year, type='show', vidtype='show', session=session, admin=True, all_seasons=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=title, thumb=thumb, summary=summary, purl=None, season=None, season_end=SeasonNR+1, episode_start=1, episode_end=None, year=year, type='show', vidtype='show', session=session, admin=True, all_seasons=True, imdbid=imdbid), title = 'Add to AutoPilot Queue', summary = 'Adds Season (1 - %s) to the AutoPilot Queue for Downloading' % (SeasonNR), thumb = R(common.ICON_OTHERSOURCESDOWNLOAD_AUTO) @@ -6486,7 +6504,7 @@ def DoIMDBExtSources(title, year, type, imdbid, season=None, episode=None, episo if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: autopilot_option_shown = True oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=x_title, thumb=x_thumb, summary=x_summary, purl=None, season=x_season, episode_start=1, episode_end=e, year=x_year, type='show', vidtype='show', session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=x_title, thumb=x_thumb, summary=x_summary, purl=None, season=x_season, episode_start=1, episode_end=e, year=x_year, type='show', vidtype='show', session=session, admin=True, imdbid=x_imdbid), title = 'Add to AutoPilot Queue', summary = 'Adds Episodes (1 - %s) to the AutoPilot Queue for Downloading' % (e-1), thumb = R(common.ICON_OTHERSOURCESDOWNLOAD_AUTO) @@ -6558,7 +6576,7 @@ def DoIMDBExtSources(title, year, type, imdbid, season=None, episode=None, episo episodesTot = int(episodesTot) if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=x_title, thumb=x_thumb, summary=x_summary, purl=None, season=x_season, episode_start=1, episode_end=episodesTot, year=x_year, type='show', vidtype='show', session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=x_title, thumb=x_thumb, summary=x_summary, purl=None, season=x_season, episode_start=1, episode_end=episodesTot, year=x_year, type='show', vidtype='show', session=session, admin=True, imdbid=x_imdbid), title = 'Add to AutoPilot Queue', summary = 'Adds Episodes (1 - %s) to the AutoPilot Queue for Downloading' % episodesTot, thumb = R(common.ICON_OTHERSOURCESDOWNLOAD_AUTO) @@ -6575,7 +6593,7 @@ def DoIMDBExtSources(title, year, type, imdbid, season=None, episode=None, episo episodesTot = int(episodesTot) if Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: oc.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=x_title, thumb=x_thumb, summary=x_summary, purl=None, season=x_season, episode_start=1, episode_end=episodesTot, year=x_year, type='show', vidtype='show', session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=x_title, thumb=x_thumb, summary=x_summary, purl=None, season=x_season, episode_start=1, episode_end=episodesTot, year=x_year, type='show', vidtype='show', session=session, admin=True, imdbid=x_imdbid), title = 'Add to AutoPilot Queue', summary = 'Adds Episodes (1 - %s) to the AutoPilot Queue for Downloading' % episodesTot, thumb = R(common.ICON_OTHERSOURCESDOWNLOAD_AUTO) @@ -7530,7 +7548,7 @@ def season_menuES(title, show_title, season_index, dataEXSJsonUrl, session): if len(object_container) > 0 and Prefs['disable_downloader'] == False and AuthTools.CheckAdmin() == True: object_container.add(DirectoryObject( - key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=common.cleantitle.removeParanthesisAndSeason(show_title, season_index), thumb=thumb, summary='Summary Unavailable', purl=dataEXSJsonUrl, season=season_index, episode_start=1, episode_end=episode_end, year=json_data['year'], type='show', vidtype='show', session=session, admin=True), + key = Callback(downloadsmenu.AddToAutoPilotDownloads, title=common.cleantitle.removeParanthesisAndSeason(show_title, season_index), thumb=thumb, summary='Summary Unavailable', purl=dataEXSJsonUrl, season=season_index, episode_start=1, episode_end=episode_end, year=json_data['year'], type='show', vidtype='show', session=session, admin=True, imdbid=json_data['_id']), title = 'Add to AutoPilot Queue', summary = 'Add to the AutoPilot Queue for Downloading', art = art, diff --git a/Contents/Libraries/Shared/resources/lib/libraries/source_utils.py b/Contents/Libraries/Shared/resources/lib/libraries/source_utils.py index 024c158..6452764 100644 --- a/Contents/Libraries/Shared/resources/lib/libraries/source_utils.py +++ b/Contents/Libraries/Shared/resources/lib/libraries/source_utils.py @@ -261,4 +261,15 @@ def evpKDF(passwd, salt, key_size=8, iv_size=4, iterations=1, hash_algorithm="md return { "key": derived_bytes[0: key_size * 4], "iv": derived_bytes[key_size * 4:] - } \ No newline at end of file + } + +def aliases_to_array(aliases, filter=None): + try: + if not filter: + filter = [] + if isinstance(filter, str): + filter = [filter] + + return [x.get('title') for x in aliases if not filter or x.get('country') in filter] + except: + return [] \ No newline at end of file diff --git a/Contents/Libraries/Shared/resources/lib/resolvers/host_direct.py b/Contents/Libraries/Shared/resources/lib/resolvers/host_direct.py index 7890b62..6b5d773 100644 --- a/Contents/Libraries/Shared/resources/lib/resolvers/host_direct.py +++ b/Contents/Libraries/Shared/resources/lib/resolvers/host_direct.py @@ -49,8 +49,8 @@ def __init__(self): self.init = False self.logo = 'https://i.imgur.com/nbtnvDr.png' self.name = name - self.host = ['imdb.com','media-imdb.com','einthusan.tv','vimeocdn.com','apple.com','akamaized.net','micetop.us','vidcdn.pro','fbcdn.net','cmovieshd.com', 'vcstream.to', 'documentarymania.com','3donlinefilms.com','3dmoviesfullhd.com','totaleclips.com','freedocufilms.com','cartoonhd.pw'] - self.netloc = ['imdb.com','media-imdb.com','einthusan.tv','vimeocdn.com','apple.com','akamaized.net','micetop.us','vidcdn.pro','fbcdn.net','cmovieshd.com', 'vcstream.to', 'documentarymania.com','3donlinefilms.com','3dmoviesfullhd.com','totaleclips.com','freedocufilms.com','cartoonhd.pw'] + self.host = ['imdb.com','media-imdb.com','einthusan.tv','vimeocdn.com','apple.com','akamaized.net','micetop.us','vidcdn.pro','fbcdn.net','cmovieshd.com', 'vcstream.to', 'documentarymania.com','3donlinefilms.com','3dmoviesfullhd.com','totaleclips.com','freedocufilms.com','cartoonhd.pw','cooltvseries.com'] + self.netloc = ['imdb.com','media-imdb.com','einthusan.tv','vimeocdn.com','apple.com','akamaized.net','micetop.us','vidcdn.pro','fbcdn.net','cmovieshd.com', 'vcstream.to', 'documentarymania.com','3donlinefilms.com','3dmoviesfullhd.com','totaleclips.com','freedocufilms.com','cartoonhd.pw','cooltvseries.com'] self.quality = '1080p' self.loggertxt = [] self.captcha = False @@ -240,6 +240,21 @@ def process(self, url, q, r, headers, page_url): params = client.b64encode(json.dumps(paramsx, encoding='utf-8')) items.append({'quality':q, 'riptype':r, 'src':url, 'fs':fs, 'online':online, 'params':params, 'urldata':urldata, 'allowsStreaming':False, 'allowsDownload':True}) + elif 'cooltvseries.com' in url: + urlx = client.request(url, output='geturl', headers=headers) + urlx = '%s?e=file.mp4' % urlx + fs = client.getFileSize(url, retry429=True, headers=headers) + if fs == None or int(fs) == 0: + fs = client.getFileSize(url, retry429=True) + q = qual_based_on_fs(q,fs) + online = check(url) + urldata = client.b64encode(json.dumps('', encoding='utf-8')) + params = client.b64encode(json.dumps('', encoding='utf-8')) + if headers != None: + paramsx = {'headers':headers} + params = client.b64encode(json.dumps(paramsx, encoding='utf-8')) + allowsDownload = True + items.append({'quality':q, 'riptype':r, 'src':urlx, 'fs':fs, 'online':online, 'params':params, 'urldata':urldata, 'allowsStreaming':True, 'allowsDownload':allowsDownload}) else: fs = client.getFileSize(url, retry429=True, headers=headers) if fs == None or int(fs) == 0: @@ -274,12 +289,16 @@ def process(self, url, q, r, headers, page_url): return items -def qual_based_on_fs(q,fs): +def qual_based_on_fs(q, fs): try: - if int(fs) > 2 * float(1024*1024*1024): + if int(fs) > 1.75 * float(1024*1024*1024): q = '1080p' - elif int(fs) > 1 * float(1024*1024*1024): + elif int(fs) > 0.5 * float(1024*1024*1024): q = '720p' + elif int(fs) < 0.3 * float(1024*1024*1024): + q = '480p' + else: + q = '360p' except: pass return q diff --git a/Contents/Libraries/Shared/resources/lib/resolvers/host_mega.py b/Contents/Libraries/Shared/resources/lib/resolvers/host_mega.py index d53ecdc..008cadb 100644 --- a/Contents/Libraries/Shared/resources/lib/resolvers/host_mega.py +++ b/Contents/Libraries/Shared/resources/lib/resolvers/host_mega.py @@ -310,13 +310,17 @@ def createurldata(mfile, qual): ret = json.dumps(ret, encoding='utf-8') return client.b64encode(ret) - -def qual_based_on_fs(q,fs): + +def qual_based_on_fs(q, fs): try: - if int(fs) > 2 * float(1024*1024*1024): + if int(fs) > 1.75 * float(1024*1024*1024): q = '1080p' - elif int(fs) > 1 * float(1024*1024*1024): + elif int(fs) > 0.5 * float(1024*1024*1024): q = '720p' + elif int(fs) < 0.3 * float(1024*1024*1024): + q = '480p' + else: + q = '360p' except: pass return q diff --git a/Contents/Libraries/Shared/resources/lib/resolvers/host_mp4upload.py b/Contents/Libraries/Shared/resources/lib/resolvers/host_mp4upload.py index 38fb73e..4bf0e7c 100644 --- a/Contents/Libraries/Shared/resources/lib/resolvers/host_mp4upload.py +++ b/Contents/Libraries/Shared/resources/lib/resolvers/host_mp4upload.py @@ -295,13 +295,19 @@ def getAllQuals(url, online=None): e = '{}'.format(e) return (None, e, None) + def qual_based_on_fs(fs): - q = '480p' try: - if int(fs) > 2 * float(1024*1024*1024): + q = '480p' + + if int(fs) > 1.75 * float(1024*1024*1024): q = '1080p' - elif int(fs) > 1 * float(1024*1024*1024): + elif int(fs) > 0.5 * float(1024*1024*1024): q = '720p' + elif int(fs) < 0.3 * float(1024*1024*1024): + q = '480p' + else: + q = '360p' except: pass return q diff --git a/Contents/Libraries/Shared/resources/lib/resolvers/host_vidcloud.py b/Contents/Libraries/Shared/resources/lib/resolvers/host_vidcloud.py index 340d5d3..38324b9 100644 --- a/Contents/Libraries/Shared/resources/lib/resolvers/host_vidcloud.py +++ b/Contents/Libraries/Shared/resources/lib/resolvers/host_vidcloud.py @@ -299,12 +299,16 @@ def resolve(url, online=None, page_url=None, **kwargs): e = '{}'.format(e) return (None, e, None) -def qual_based_on_fs(q,fs): +def qual_based_on_fs(q, fs): try: - if int(fs) > 2 * float(1024*1024*1024): + if int(fs) > 1.75 * float(1024*1024*1024): q = '1080p' - elif int(fs) > 1 * float(1024*1024*1024): + elif int(fs) > 0.5 * float(1024*1024*1024): q = '720p' + elif int(fs) < 0.3 * float(1024*1024*1024): + q = '480p' + else: + q = '360p' except: pass return q diff --git a/Contents/Libraries/Shared/resources/lib/resolvers/host_xstreamcdn.py b/Contents/Libraries/Shared/resources/lib/resolvers/host_xstreamcdn.py index b487b3d..d39cbf9 100644 --- a/Contents/Libraries/Shared/resources/lib/resolvers/host_xstreamcdn.py +++ b/Contents/Libraries/Shared/resources/lib/resolvers/host_xstreamcdn.py @@ -292,13 +292,16 @@ def getAllQuals(url, page_url, online=None): e = '{}'.format(e) return (None, e, None) -def qual_based_on_fs(fs): - q = '480p' +def qual_based_on_fs(q, fs): try: - if int(fs) > 2 * float(1024*1024*1024): + if int(fs) > 1.75 * float(1024*1024*1024): q = '1080p' - elif int(fs) > 1 * float(1024*1024*1024): + elif int(fs) > 0.5 * float(1024*1024*1024): q = '720p' + elif int(fs) < 0.3 * float(1024*1024*1024): + q = '480p' + else: + q = '360p' except: pass return q diff --git a/Contents/Libraries/Shared/resources/lib/sources/cooltvseries_ex.py b/Contents/Libraries/Shared/resources/lib/sources/cooltvseries_ex.py new file mode 100644 index 0000000..ee554dd --- /dev/null +++ b/Contents/Libraries/Shared/resources/lib/sources/cooltvseries_ex.py @@ -0,0 +1,308 @@ +# -*- coding: utf-8 -*- + +# Coder Alpha +# https://github.com/coder-alpha +# + +''' + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +''' +######################################################################################################### + +import re,urllib,urlparse,json,random,time,base64 +from resources.lib.libraries import control +from resources.lib.libraries import cleantitle +from resources.lib.libraries import client +from resources.lib.libraries import testparams +from resources.lib.libraries import workers +from resources.lib import resolvers +from resources.lib import proxies + +name = 'CoolTvSeries' +loggertxt = [] + +class source: + def __init__(self): + del loggertxt[:] + self.ver = '0.0.1' + self.update_date = 'Apr. 16, 2019' + log(type='INFO', method='init', err=' -- Initializing %s %s %s Start --' % (name, self.ver, self.update_date)) + self.init = False + self.refreshCookies = False + self.disabled = False + self.base_link_alts = ['https://cooltvseries.com'] + self.base_link = self.base_link_alts[0] + self.MainPageValidatingContent = ['TV Series Download - TV Shows Download | CooLTVSeries'] + self.type_filter = ['show'] + self.search_link = '/%s/season-%s/' + self.ssl = False + self.name = name + self.headers = {} + self.cookie = None + self.loggertxt = [] + self.logo = 'https://i.imgur.com/dSyDD94.png' + self.speedtest = 0 + if len(proxies.sourceProxies)==0: + proxies.init() + self.proxyrequired = False + self.msg = '' + self.siteonline = self.testSite() + self.testparser = 'Unknown' + self.testparser = self.testParser() + self.initAndSleepThread() + self.firstRunDisabled = False + self.init = True + log(type='INFO', method='init', err=' -- Initializing %s %s %s End --' % (name, self.ver, self.update_date)) + + def info(self): + return { + 'url': self.base_link, + 'name': self.name, + 'msg' : self.msg, + 'speed': round(self.speedtest,3), + 'logo': self.logo, + 'ssl' : self.ssl, + 'frd' : self.firstRunDisabled, + 'online': self.siteonline, + 'online_via_proxy' : self.proxyrequired, + 'parser': self.testparser + } + + def getLog(self): + self.loggertxt = loggertxt + return self.loggertxt + + def testSite(self): + for site in self.base_link_alts: + try: + sitex = client.getRedirectingUrl(site).strip("/") + if 'http' not in sitex: + raise Exception('Error in geturl') + else: + site = sitex + except: + pass + bool = self.testSiteAlts(site) + if bool == True: + return bool + + self.base_link = self.base_link_alts[0] + return False + + def testSiteAlts(self, site): + try: + self.base_link = site + if self.disabled: + log('INFO','testSite', 'Plugin Disabled') + return False + self.initAndSleep() + x1 = time.time() + http_res, content = proxies.request(url=site, headers=self.headers, output='response', use_web_proxy=False, httpsskip=True) + self.speedtest = time.time() - x1 + for valcon in self.MainPageValidatingContent: + if content != None and content.find(valcon) >-1: + log('SUCCESS', 'testSite', 'HTTP Resp : %s for %s' % (http_res,site)) + return True + log('FAIL', 'testSite', 'Validation content Not Found. HTTP Resp : %s for %s' % (http_res,site)) + return False + except Exception as e: + log('ERROR','testSite', '%s' % e) + return False + + def initAndSleepThread(self): + if self.refreshCookies == False: + return + thread_i = workers.Thread(self.InitSleepThread) + thread_i.start() + + def InitSleepThread(self): + try: + while self.init == True: + tuid = control.id_generator(16) + control.AddThread('%s-InitSleepThread' % self.name, 'Persists & Monitors Provider Requirements (Every 60 mins.)', time.time(), '4', True, tuid) + time.sleep(60*60) + self.siteonline = self.testSite() + self.testparser = self.testParser() + self.initAndSleep() + control.RemoveThread(tuid) + except Exception as e: + log('ERROR','InitSleepThread', '%s' % e) + control.RemoveThread(tuid) + + def initAndSleep(self): + try: + t_base_link = self.base_link + self.headers = {'X-Requested-With': 'XMLHttpRequest'} + self.headers['Referer'] = t_base_link + ua = client.randomagent() + self.headers['User-Agent'] = ua + + #get cf cookie + cookie = proxies.request(url=t_base_link, headers=self.headers, output='cookie', use_web_proxy=self.proxyrequired, httpsskip=True) + self.headers['Cookie'] = cookie + log('SUCCESS', 'initAndSleep', 'Cookies : %s for %s' % (cookie,self.base_link)) + except Exception as e: + log('ERROR','initAndSleep', '%s' % e) + + def testParser(self): + try: + if control.setting('Provider-%s' % name) == False: + log('INFO','testParser', 'Plugin Disabled by User - cannot test parser') + return False + if control.setting('use_quick_init') == True: + log('INFO','testParser', 'Disabled testing - Using Quick Init setting in Prefs.') + return False + if self.disabled == True: + log('INFO','testParser', 'Plugin Disabled - cannot test parser') + return False + if self.siteonline == False: + log('INFO', 'testParser', '%s is offline - cannot test parser' % self.base_link) + return False + + for show in testparams.test_shows: + geturl = self.get_show(tvshowtitle=show['title'], season=show['season'], year=show['year']) + geturl = self.get_episode(geturl, episode=show['episode']) + links = self.get_sources(url=geturl, testing=True) + + if links != None and len(links) > 0: + log('SUCCESS', 'testParser', 'Parser is working') + return True + + log('FAIL', 'testParser', 'Parser NOT working') + return False + except Exception as e: + log('ERROR', 'testParser', '%s' % e) + return False + + def get_movie(self, imdb, title, year, proxy_options=None, key=None): + try: + if control.setting('Provider-%s' % name) == False: + log('INFO','get_movie','Provider Disabled by User') + return None + if self.siteonline == False: + log('INFO','get_movie','Provider is Offline') + return None + url = {'imdb': imdb, 'title': title, 'year': year} + url = urllib.urlencode(url) + return url + except Exception as e: + log('ERROR', 'get_movie','%s: %s' % (title,e), dolog=self.init) + return + + def get_show(self, imdb=None, tvdb=None, tvshowtitle=None, year=None, season=None, proxy_options=None, key=None): + try: + if control.setting('Provider-%s' % name) == False: + log('INFO','get_show','Provider Disabled by User') + return None + if self.siteonline == False: + log('INFO','get_show','Provider is Offline') + return None + + try: + url = cleantitle.geturl(tvshowtitle) + return url + except: + return + + except Exception as e: + log('ERROR', 'get_show','%s: %s' % (tvshowtitle,e), dolog=self.init) + return + + def get_episode(self, url=None, imdb=None, tvdb=None, title=None, year=None, season=None, episode=None, proxy_options=None, key=None): + try: + if control.setting('Provider-%s' % name) == False: + return None + if url == None: return + + try: + if not url: return + http = self.base_link + self.search_link % (url,season) + season = '%02d' % int(season) + episode = '%02d' % int(episode) + r = client.request(http) + match = re.compile('').findall(r) + for url1,url2 in match: + url = '%s-S%sE%s-%s' % (url1,season,episode,url2) + return url + except: + return + + except Exception as e: + log('ERROR', 'get_episode','%s: %s' % (title,e), dolog=self.init) + return + + def get_sources(self, url, hosthdDict=None, hostDict=None, locDict=None, proxy_options=None, key=None, testing=False): + try: + sources = [] + if control.setting('Provider-%s' % name) == False: + log('INFO','get_sources','Provider Disabled by User') + log('INFO', 'get_sources', 'Completed') + return sources + if url == None: + log('FAIL','get_sources','url == None. Could not find a matching title: %s' % cleantitle.title_from_key(key), dolog=not testing) + log('INFO', 'get_sources', 'Completed') + return sources + + links_m = [] + page_url = url + r = client.request(url) + try: + match = re.compile('
  • (.+?)<').findall(r) + for url, check in match: + quality = '720p' + poster = None + riptype = 'BRRIP' + vidtype = 'Show' + sub_url = None + l = resolvers.createMeta(url, self.name, self.logo, quality, [], key, poster=poster, riptype=riptype, vidtype=vidtype, sub_url=sub_url, testing=testing, page_url=page_url) + for ll in l: + if ll != None and 'key' in ll.keys(): + links_m.append(ll) + except: + return + + for l in links_m: + if l != None and 'key' in l.keys(): + sources.append(l) + + if len(sources) == 0: + log('FAIL','get_sources','Could not find a matching title: %s' % cleantitle.title_from_key(key)) + else: + log('SUCCESS', 'get_sources','%s sources : %s' % (cleantitle.title_from_key(key), len(sources))) + + log('INFO', 'get_sources', 'Completed') + + return sources + except Exception as e: + log('ERROR', 'get_sources', '%s' % e) + log('INFO', 'get_sources', 'Completed') + return sources + + def resolve(self, url): + try: + return url + except: + return + +def log(type='INFO', method='undefined', err='', dolog=True, logToControl=False, doPrint=True): + try: + msg = '%s: %s > %s > %s : %s' % (time.ctime(time.time()), type, name, method, err) + if dolog == True: + loggertxt.append(msg) + if logToControl == True: + control.log(msg) + if control.doPrint == True and doPrint == True: + print msg + except Exception as e: + control.log('Error in Logging: %s >>> %s' % (msg,e)) diff --git a/Contents/Libraries/Shared/resources/lib/sources/seriesfree_ex.py b/Contents/Libraries/Shared/resources/lib/sources/seriesfree_ex.py new file mode 100644 index 0000000..1d5d067 --- /dev/null +++ b/Contents/Libraries/Shared/resources/lib/sources/seriesfree_ex.py @@ -0,0 +1,378 @@ +# -*- coding: utf-8 -*- + +# Coder Alpha +# https://github.com/coder-alpha +# + +''' + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +''' +######################################################################################################### + +import re,urllib,urlparse,json,random,time,base64 +from resources.lib.libraries import control +from resources.lib.libraries import cleantitle +from resources.lib.libraries import client +from resources.lib.libraries import testparams +from resources.lib.libraries import workers +from resources.lib.libraries import source_utils +from resources.lib import resolvers +from resources.lib import proxies + +name = 'SeriesFree' +loggertxt = [] + +class source: + def __init__(self): + del loggertxt[:] + self.ver = '0.0.1' + self.update_date = 'Apr. 16, 2019' + log(type='INFO', method='init', err=' -- Initializing %s %s %s Start --' % (name, self.ver, self.update_date)) + self.init = False + self.refreshCookies = False + self.disabled = False + self.base_link_alts = ['https://seriesfree.to','https://watchseriesfree.to'] + self.base_link = self.base_link_alts[0] + self.MainPageValidatingContent = ['Watch Series Online FREE, full episodes - Series Free'] + self.type_filter = ['show'] + self.search_link = 'https://seriesfree.to/search/%s' + self.ssl = False + self.name = name + self.headers = {} + self.cookie = None + self.loggertxt = [] + self.logo = 'https://i.imgur.com/lLWr1hW.png' + self.speedtest = 0 + if len(proxies.sourceProxies)==0: + proxies.init() + self.proxyrequired = False + self.msg = '' + self.siteonline = self.testSite() + self.testparser = 'Unknown' + self.testparser = self.testParser() + self.initAndSleepThread() + self.firstRunDisabled = False + self.init = True + log(type='INFO', method='init', err=' -- Initializing %s %s %s End --' % (name, self.ver, self.update_date)) + + def info(self): + return { + 'url': self.base_link, + 'name': self.name, + 'msg' : self.msg, + 'speed': round(self.speedtest,3), + 'logo': self.logo, + 'ssl' : self.ssl, + 'frd' : self.firstRunDisabled, + 'online': self.siteonline, + 'online_via_proxy' : self.proxyrequired, + 'parser': self.testparser + } + + def getLog(self): + self.loggertxt = loggertxt + return self.loggertxt + + def testSite(self): + for site in self.base_link_alts: + try: + sitex = client.getRedirectingUrl(site).strip("/") + if 'http' not in sitex: + raise Exception('Error in geturl') + else: + site = sitex + except: + pass + bool = self.testSiteAlts(site) + if bool == True: + self.search_link = '%s%s' % (site, '/search/%s') + return bool + + self.base_link = self.base_link_alts[0] + return False + + def testSiteAlts(self, site): + try: + self.base_link = site + if self.disabled: + log('INFO','testSite', 'Plugin Disabled') + return False + self.initAndSleep() + x1 = time.time() + http_res, content = proxies.request(url=site, headers=self.headers, output='response', use_web_proxy=False, httpsskip=True) + self.speedtest = time.time() - x1 + for valcon in self.MainPageValidatingContent: + if content != None and content.find(valcon) >-1: + log('SUCCESS', 'testSite', 'HTTP Resp : %s for %s' % (http_res,site)) + return True + log('FAIL', 'testSite', 'Validation content Not Found. HTTP Resp : %s for %s' % (http_res,site)) + return False + except Exception as e: + log('ERROR','testSite', '%s' % e) + return False + + def initAndSleepThread(self): + if self.refreshCookies == False: + return + thread_i = workers.Thread(self.InitSleepThread) + thread_i.start() + + def InitSleepThread(self): + try: + while self.init == True: + tuid = control.id_generator(16) + control.AddThread('%s-InitSleepThread' % self.name, 'Persists & Monitors Provider Requirements (Every 60 mins.)', time.time(), '4', True, tuid) + time.sleep(60*60) + self.siteonline = self.testSite() + self.testparser = self.testParser() + self.initAndSleep() + control.RemoveThread(tuid) + except Exception as e: + log('ERROR','InitSleepThread', '%s' % e) + control.RemoveThread(tuid) + + def initAndSleep(self): + try: + t_base_link = self.base_link + self.headers = {'X-Requested-With': 'XMLHttpRequest'} + self.headers['Referer'] = t_base_link + ua = client.randomagent() + self.headers['User-Agent'] = ua + + #get cf cookie + cookie = proxies.request(url=t_base_link, headers=self.headers, output='cookie', use_web_proxy=self.proxyrequired, httpsskip=True) + self.headers['Cookie'] = cookie + log('SUCCESS', 'initAndSleep', 'Cookies : %s for %s' % (cookie,self.base_link)) + except Exception as e: + log('ERROR','initAndSleep', '%s' % e) + + def testParser(self): + try: + if control.setting('Provider-%s' % name) == False: + log('INFO','testParser', 'Plugin Disabled by User - cannot test parser') + return False + if control.setting('use_quick_init') == True: + log('INFO','testParser', 'Disabled testing - Using Quick Init setting in Prefs.') + return False + if self.disabled == True: + log('INFO','testParser', 'Plugin Disabled - cannot test parser') + return False + if self.siteonline == False: + log('INFO', 'testParser', '%s is offline - cannot test parser' % self.base_link) + return False + + for show in testparams.test_shows: + geturl = self.get_show(tvshowtitle=show['title'], season=show['season'], year=show['year']) + geturl = self.get_episode(geturl, episode=show['episode']) + links = self.get_sources(url=geturl, testing=True) + + if links != None and len(links) > 0: + log('SUCCESS', 'testParser', 'Parser is working') + return True + + log('FAIL', 'testParser', 'Parser NOT working') + return False + except Exception as e: + log('ERROR', 'testParser', '%s' % e) + return False + + def get_movie(self, imdb, title, year, proxy_options=None, key=None): + try: + if control.setting('Provider-%s' % name) == False: + log('INFO','get_movie','Provider Disabled by User') + return None + if self.siteonline == False: + log('INFO','get_movie','Provider is Offline') + return None + url = {'imdb': imdb, 'title': title, 'year': year} + url = urllib.urlencode(url) + return url + except Exception as e: + log('ERROR', 'get_movie','%s: %s' % (title,e), dolog=self.init) + return + + def get_show(self, imdb=None, tvdb=None, tvshowtitle=None, year=None, season=None, proxy_options=None, key=None): + try: + if control.setting('Provider-%s' % name) == False: + log('INFO','get_show','Provider Disabled by User') + return None + if self.siteonline == False: + log('INFO','get_show','Provider is Offline') + return None + + try: + query = self.search_link % urllib.quote_plus(cleantitle.query(tvshowtitle)) + + for i in range(5): + result = client.request(query) + if result == None or str(result) == '502': + log('FAIL', 'get_show','result error, trying again', dolog=self.init) + time.sleep(7) + if not result == None and str(result) != '502': break + + #tvshowtitle = cleantitle.get(tvshowtitle) + t = [tvshowtitle] + source_utils.aliases_to_array(None) + t = [cleantitle.get(i) for i in set(t) if i] + result = re.compile('itemprop="url"\s+href="([^"]+).*?itemprop="name"\s+class="serie-title">([^<]+)', re.DOTALL).findall(result) + for i in result: + if cleantitle.get(cleantitle.normalize(i[1])) in t and year in i[1]: url = i[0] + + url = url.encode('utf-8') + return url + except Exception as e: + log('FAIL', 'get_show','%s: %s' % (tvshowtitle,e), dolog=self.init) + return + + except Exception as e: + log('ERROR', 'get_show','%s: %s' % (tvshowtitle,e), dolog=self.init) + return + + def get_episode(self, url=None, imdb=None, tvdb=None, title=None, year=None, season=None, episode=None, proxy_options=None, key=None): + try: + if control.setting('Provider-%s' % name) == False: + return None + if url == None: return + + try: + if url == None: return + + url = urlparse.urljoin(self.base_link, url) + for i in range(5): + result = client.request(url, timeout=7) + if result == None or str(result) == '502': + log('FAIL', 'get_episode','result error, trying again', dolog=self.init) + time.sleep(7) + if not result == None and str(result) != '502': break + + title = cleantitle.get(title) + items = client.parseDOM(result, 'li', attrs={'itemprop':'episode'}) + items_a = [client.parseDOM(i, 'input')[0] for i in items] + + url = [client.parseDOM(i, 'a', ret='href')[0] for i in items_a if bool(re.compile('Season %s Episode %s' % (season,episode)).search(i))] + + url = url[0] + url = url.encode('utf-8') + return url + except Exception as e: + log('FAIL', 'get_episode','%s: %s' % (title,e), dolog=self.init) + return + + except Exception as e: + log('ERROR', 'get_episode','%s: %s' % (title,e), dolog=self.init) + return + + def get_sources(self, url, hosthdDict=None, hostDict=None, locDict=None, proxy_options=None, key=None, testing=False): + try: + sources = [] + if control.setting('Provider-%s' % name) == False: + log('INFO','get_sources','Provider Disabled by User') + log('INFO', 'get_sources', 'Completed') + return sources + if url == None: + log('FAIL','get_sources','url == None. Could not find a matching title: %s' % cleantitle.title_from_key(key), dolog=not testing) + log('INFO', 'get_sources', 'Completed') + return sources + + links_m = [] + page_url = url + quality = '720p' + poster = None + riptype = 'BRRIP' + vidtype = 'Show' + sub_url = None + + if url == None: return sources + url = urlparse.urljoin(self.base_link, url) + for i in range(5): + result = client.request(url, timeout=7) + if result == None or str(result) == '502': + log('FAIL', 'get_sources','result error, trying again', dolog=self.init) + time.sleep(7) + if not result == None and str(result) != '502': break + + dom = client.parseDOM(result, 'div', attrs={'class':'links', 'id': 'noSubs'}) + result = dom[0] + + #links = re.compile('\s*([^<]+).*?href="([^"]+)"\s+class="watch',re.DOTALL).findall(result) + links = client.parseDOM(result, 'a', attrs={'class':'watch-btn btn btn-success btn-3d'}, ret='href') + #print links + try: + links_src = client.parseDOM(result, 'td') + #print links_src + links_src2 = [re.findall(r'(.*?) ', i)[0].strip() for i in links_src if 'fa fa-youtube link-logo' in i] + except: + links_src2 = [] + + ii = 0 + for link in links: + try: + src = links_src2[ii] + except: + src = 'unknown' + + ii += 1 + try: + if src.lower() in ['openload','streamango','unknown']: + url2 = urlparse.urljoin(self.base_link, link) + for i in range(5): + result2 = client.request(url2, timeout=7) + if result2 == None or str(result2) == '502': + log('FAIL', 'get_sources','result error, trying again', dolog=self.init) + time.sleep(7) + if not result2 == None and str(result2) != '502': break + + r = re.compile('href="([^"]+)"\s+class="action-btn').findall(result2)[0] + + l = resolvers.createMeta(r, self.name, self.logo, quality, [], key, poster=poster, riptype=riptype, vidtype=vidtype, sub_url=sub_url, testing=testing, page_url=page_url) + for ll in l: + if ll != None and 'key' in ll.keys(): + links_m.append(ll) + + except: + pass + + for l in links_m: + if l != None and 'key' in l.keys(): + sources.append(l) + + if len(sources) == 0: + log('FAIL','get_sources','Could not find a matching title: %s' % cleantitle.title_from_key(key)) + else: + log('SUCCESS', 'get_sources','%s sources : %s' % (cleantitle.title_from_key(key), len(sources))) + + log('INFO', 'get_sources', 'Completed') + + return sources + except Exception as e: + log('ERROR', 'get_sources', '%s' % e) + log('INFO', 'get_sources', 'Completed') + return sources + + def resolve(self, url): + try: + return url + except: + return + +def log(type='INFO', method='undefined', err='', dolog=True, logToControl=False, doPrint=True): + try: + msg = '%s: %s > %s > %s : %s' % (time.ctime(time.time()), type, name, method, err) + if dolog == True: + loggertxt.append(msg) + if logToControl == True: + control.log(msg) + if control.doPrint == True and doPrint == True: + print msg + except Exception as e: + control.log('Error in Logging: %s >>> %s' % (msg,e))