diff --git a/Contents/Code/common.py b/Contents/Code/common.py index dfe034d..3dafec5 100644 --- a/Contents/Code/common.py +++ b/Contents/Code/common.py @@ -1,6 +1,6 @@ ################################################################################ TITLE = "FMoviesPlus" -VERSION = '0.77' # Release notation (x.y - where x is major and y is minor) +VERSION = '0.78' # Release notation (x.y - where x is major and y is minor) TAG = '' GITHUB_REPOSITORY = 'coder-alpha/FMoviesPlus.bundle' PREFIX = "/video/fmoviesplus" @@ -79,6 +79,8 @@ EMOJI_ANIME = u'\u2318' EMOJI_EXT = u'*' EMOJI_GLASSES = u'\U0001F453' +EMOJI_DOWNARROW = u'\U00012B07' +EMOJI_DOWNARROW2 = u'\U0001F53B' # Simple Emoji's EMOJI_HEART = u'\u2665' @@ -129,9 +131,10 @@ DEVICE_OPTIONS[12]:'Downloads-Listing - Reverse the order of Downloads i.e. oldest entry on top', DEVICE_OPTIONS[13]:'Force-Transcoding (IMDb) - Force transcoding IMDb videos by PMS'} -GLOBAL_OPTIONS = ['Retry-Failed-Downloads','Dont-Refresh-Library-Downloads'] +GLOBAL_OPTIONS = ['Retry-Failed-Downloads','Dont-Refresh-Library-Downloads','Extend-Smart-Add-For-Seasons'] GLOBAL_OPTION = {GLOBAL_OPTIONS[0]:'On Plugin Initialization Retry Failed Downloads', - GLOBAL_OPTIONS[1]:'Don\'t perform a Library Section Refresh after an Item is Downloaded'} + GLOBAL_OPTIONS[1]:'Don\'t perform a Library Section Refresh after an Item is Downloaded', + GLOBAL_OPTIONS[2]:'Extend Smart Add AutoPilot Option for Seasons as well'} DEVICE_OPTION_CONSTRAINTS = {DEVICE_OPTIONS[2]:[{'Pref':'use_https_alt','Desc':'Use Alternate SSL/TLS','ReqValue':'disabled'}]} DEVICE_OPTION_CONSTRAINTS2 = {DEVICE_OPTIONS[5]:[{'Option':6,'ReqValue':False}], DEVICE_OPTIONS[6]:[{'Option':5,'ReqValue':False}]} diff --git a/Contents/Code/download.py b/Contents/Code/download.py index 65bc587..5b5c1ff 100644 --- a/Contents/Code/download.py +++ b/Contents/Code/download.py @@ -20,6 +20,9 @@ Dict['DOWNLOAD_RATE_LIMIT_TIME'] = [] REMAP_EXTRAS = {'behind the scenes':'behindthescenes', 'deleted scenes':'deleted', 'featurette':'featurette', 'interviews':'interview', 'misc.':'scene', 'music video':'short', 'trailer':'trailer'} +AUTOPILOT_SCHEDULER = [False] +AUTOPILOT_SCHEDULER_POST_REFRESH = [] + QUEUE_RUN_ITEMS = {} WAIT_AND_RETRY_ON_429 = True CONNECTION_TIMEOUT = 60 @@ -817,11 +820,37 @@ def download_completed(final_abs_path, section_title, section_key, purgeKey, fil else: Log('Download Completed - %s' % final_abs_path) - if fileExists == False and common.UsingOption(key=common.GLOBAL_OPTIONS[1], session='None') == False: + if fileExists == False and common.UsingOption(key=common.GLOBAL_OPTIONS[1], session='None') == False and AUTOPILOT_SCHEDULER[0] == False: Thread.Create(refresh_section, {}, section_title, section_key) - + + if fileExists == False and common.UsingOption(key=common.GLOBAL_OPTIONS[1], session='None') == False and AUTOPILOT_SCHEDULER[0] == True: + AUTOPILOT_SCHEDULER_POST_REFRESH.append([section_title, section_key]) + Thread.Create(trigger_que_run) +def post_autopilot_refresh(): + + tuid = common.id_generator(16) + common.control.AddThread('PostAutoPilotRefreshSections', 'Refresh Sections after AutoPilot Scheduler', time.time(), '3', False, tuid) + try: + if len(AUTOPILOT_SCHEDULER_POST_REFRESH) > 0 and AUTOPILOT_SCHEDULER[0] == True: + AUTOPILOT_SCHEDULER_POST_REFRESH = list(set(AUTOPILOT_SCHEDULER_POST_REFRESH)) + + for i in AUTOPILOT_SCHEDULER_POST_REFRESH: + refresh_section(i[0], i[1]) + + except Exception as e: + Log(e) + + try: + del AUTOPILOT_SCHEDULER[:] + del AUTOPILOT_SCHEDULER_POST_REFRESH[:] + AUTOPILOT_SCHEDULER.append(False) + except: + pass + + common.control.RemoveThread(tuid) + def download_failed(url, error, progress, startPos, purgeKey): Log('Download Failed: Error - %s' % error) diff --git a/Contents/Code/downloadsmenu.py b/Contents/Code/downloadsmenu.py index 9dbec07..e986309 100644 --- a/Contents/Code/downloadsmenu.py +++ b/Contents/Code/downloadsmenu.py @@ -14,6 +14,9 @@ ITEM_FOR_UPDATE = {} +SMART_ADD_EP_FALLOUT_DAYS = 30 +SMART_ADD_SEASON_FALLOUT_DAYS = 365 + ####################################################################################################### @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): @@ -541,14 +544,27 @@ def AutoPilotDownloadThread1(item=None, runForWaiting=False, viaRunNow=False): removeEntry = False removeEntry_item = None items_for_removal = {} + items_for_smart_add = {} if item == None: # runs via Scheduler and after Initialization (plugin restart) + try: + del download.AUTOPILOT_SCHEDULER[:] + download.AUTOPILOT_SCHEDULER.append(True) + except: + pass + for type in common.DOWNLOAD_AUTOPILOT.keys(): items_for_removal[type] = [] for item in common.DOWNLOAD_AUTOPILOT[type]: if (item['status'] == common.DOWNLOAD_AUTOPILOT_STATUS[2] or item['status'] == common.DOWNLOAD_AUTOPILOT_STATUS[6]): items_for_removal[type].append(item) - elif 'smart_add_active' in item.keys() and 'first_time' in item.keys() and item['smart_add_active'] == True and float(time.time() - item['first_time']) > float(60*60*24*15): + elif type == 'show' and 'smart_add_active_season' not in item.keys() and 'smart_add_active' in item.keys() and 'first_time' in item.keys() and item['smart_add_active'] == True and float(time.time() - item['first_time']) > float(60*60*24*SMART_ADD_EP_FALLOUT_DAYS): + if common.UsingOption(key=common.GLOBAL_OPTIONS[2], session='None') == True: + item_i = item.copy() + item_i = itemForSmartAadd(item=item_i, smarttype='season') + items_for_smart_add[type].append(item_i) + items_for_removal[type].append(item) + elif type == 'show' and 'smart_add_active_season' in item.keys() and 'first_time' in item.keys() and item['smart_add_active_season'] == True and float(time.time() - item['first_time']) > float(60*60*24*SMART_ADD_SEASON_FALLOUT_DAYS): items_for_removal[type].append(item) if (item['status'] != common.DOWNLOAD_AUTOPILOT_STATUS[2] and runForWaiting == False) or (runForWaiting == True and (item['status'] == common.DOWNLOAD_AUTOPILOT_STATUS[0] or item['status'] == common.DOWNLOAD_AUTOPILOT_STATUS[3])) or (item['status'] == common.DOWNLOAD_AUTOPILOT_STATUS[0] and float(time.time() - item['timeAdded']) > float(60*60)): sources = None @@ -605,6 +621,7 @@ def AutoPilotDownloadThread1(item=None, runForWaiting=False, viaRunNow=False): i['status'] = common.DOWNLOAD_AUTOPILOT_STATUS[6] except: pass + download.post_autopilot_refresh() else: # runs when added or via Run Now sources = None start_time = time.time() @@ -678,8 +695,6 @@ def AutoPilotDownloadThread1(item=None, runForWaiting=False, viaRunNow=False): except: pass - items_for_smart_add = {} - # remove completed entries for type_r in items_for_removal.keys(): items_for_smart_add[type_r] = [] @@ -689,19 +704,10 @@ def AutoPilotDownloadThread1(item=None, runForWaiting=False, viaRunNow=False): try: if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('Item for removal: %s S%s E%s' % (item_i['short_title'],item_i['season'],item_i['episode'])) - bool, lastep = verifyForSmart(item_i) + bool, lastep = verifyForSmart(item_i, smarttype='episode') common.DOWNLOAD_AUTOPILOT[type_r].remove(item_i) if bool == True: - item_i['episode'] = lastep + 1 - item_i['first_time'] = time.time() - item_i['smart_add_active'] = True - item_i['status'] = common.DOWNLOAD_AUTOPILOT_STATUS[1] - item_i['title'] = '%s S%sE%s' % (item_i['short_title'], item_i['season'], item_i['episode']) - item_i['uid'] = common.makeUID(item_i['short_title'], item_i['year'], item_i['quality'], item_i['file_size'], item_i['purl'], item_i['season'], item_i['episode']) - if int(item_i['episode']) < 100: - item_i['watch_title'] = '%s S%sE%02d' % (item_i['short_title'],int(item_i['season']),int(item_i['episode'])) - else: - item_i['watch_title'] = '%s S%sE%03d' % (item_i['short_title'],int(item_i['season']),int(item_i['episode'])) + item_i = itemForSmartAadd(item=item_i, smarttype='episode', lastep=lastep) items_for_smart_add[type_r].append(item_i) except Exception as e: Log.Error('ERROR: downloadsmenu.py > AutoPilotDownloadThread1 > items_for_removal: %s' % e) @@ -723,18 +729,53 @@ def AutoPilotDownloadThread1(item=None, runForWaiting=False, viaRunNow=False): common.control.RemoveThread(tuid) del AutoPilotDownloadThread1_Singleton[:] + +####################################################################################################### +def itemForSmartAadd(item=None, smarttype='episode', lastep=0): + + if item['type'] == 'show': + if type == 'episode': + item['episode'] = int(lastep) + 1 + item['first_time'] = time.time() + item['smart_add_active'] = True + if 'smart_add_active_season' in item.keys(): + del item['smart_add_active_season'] + item['status'] = common.DOWNLOAD_AUTOPILOT_STATUS[1] + item['title'] = '%s S%sE%s' % (item['short_title'], item['season'], item['episode']) + item['uid'] = common.makeUID(item['short_title'], item['year'], item['quality'], item['file_size'], item['purl'], item['season'], item['episode']) + if int(item['episode']) < 100: + item['watch_title'] = '%s S%sE%02d' % (item['short_title'],int(item['season']),int(item['episode'])) + else: + item['watch_title'] = '%s S%sE%03d' % (item['short_title'],int(item['season']),int(item['episode'])) + elif type == 'season': + item['episode'] = int(lastep) + 1 + item['season'] = int(item['season']) + 1 + item['first_time'] = time.time() + item['smart_add_active'] = True + item['smart_add_active_season'] = True + item['status'] = common.DOWNLOAD_AUTOPILOT_STATUS[1] + item['title'] = '%s S%sE%s' % (item['short_title'], item['season'], item['episode']) + item['uid'] = common.makeUID(item['short_title'], item['year'], item['quality'], item['file_size'], item['purl'], item['season'], item['episode']) + if int(item['episode']) < 100: + item['watch_title'] = '%s S%sE%02d' % (item['short_title'],int(item['season']),int(item['episode'])) + else: + item['watch_title'] = '%s S%sE%03d' % (item['short_title'],int(item['season']),int(item['episode'])) + + return item ####################################################################################################### -def verifyForSmart(item): +def verifyForSmart(item, smarttype='episode'): lastep = 0 no_items = 0 - if 'smart_add' in item.keys() and item['smart_add'] == True: - for i in common.DOWNLOAD_AUTOPILOT['show']: - if item['short_title'] == i['short_title'] and item['season'] == i['season']: - no_items += 1 - if i['episode'] > lastep: - lastep = int(i['episode']) + + if smarttype == 'episode': + if 'smart_add' in item.keys() and item['smart_add'] == True: + for i in common.DOWNLOAD_AUTOPILOT['show']: + if item['short_title'] == i['short_title'] and item['season'] == i['season']: + no_items += 1 + if i['episode'] > lastep: + lastep = int(i['episode']) if no_items == 1: return True, lastep diff --git a/Contents/Code/main.py b/Contents/Code/main.py index 4331fc2..6c60978 100644 --- a/Contents/Code/main.py +++ b/Contents/Code/main.py @@ -2480,7 +2480,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** if True: server_lab.append(label) - if common.DEV_DEBUG == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('-- %s --' % label) items = server.xpath(".//ul//li") @@ -2507,7 +2507,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** try: for cx in servers_list[common.SERVER_PLACEHOLDER]: if cx['quality'] == servers_list[label][c]['quality'] and cx['loc'] != '': - if common.DEV_DEBUG == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('%s == %s' % (int(cx['quality']), int(servers_list[label][c]['quality']))) doFill = False break @@ -2515,7 +2515,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** pass if doFill == True and len(servers_list[label][c]) > 0: - if common.DEV_DEBUG == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('c = %s' % servers_list[label][c]) if len(servers_list[common.SERVER_PLACEHOLDER]) <= c: servers_list[common.SERVER_PLACEHOLDER].append([]) @@ -2549,35 +2549,70 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** server_lab.insert(0,common.SERVER_PLACEHOLDER) # remap server list - this way its easier to iterate for tv-show episodes - servers_list_new = [] - c=0 - c_p=0 + + m_min = 0 try: - m_min = servers_list[common.SERVER_PLACEHOLDER][0]['quality'] - if '-' in m_min: - m_min = m_min.split('-') - m_min = m_min[0] - m_min = filter(lambda x: x.isdigit(), m_min) - m_min = int(m_min) + if isTvSeries == True: + m_min = servers_list[common.SERVER_PLACEHOLDER][0]['quality'] + if '-' in m_min: + m_min = m_min.split('-') + m_min = m_min[0] + m_min = filter(lambda x: x.isdigit(), m_min) + m_min = int(m_min) except: m_min = 0 + + m_max = 1 try: - m_max = servers_list[common.SERVER_PLACEHOLDER][len(servers_list[common.SERVER_PLACEHOLDER])-1]['quality'] - if '-' in m_max: - m_max = m_max.split('-') - try: - m_max = str(int(m_max[1])) - except: - m_max = m_max[0] - m_max = filter(lambda x: x.isdigit(), m_max) + if isTvSeries == True: + m_max = servers_list[common.SERVER_PLACEHOLDER][len(servers_list[common.SERVER_PLACEHOLDER])-1]['quality'] + if '-' in m_max: + m_max = m_max.split('-') + try: + m_max = str(int(m_max[1])) + except: + m_max = m_max[0] + m_max = filter(lambda x: x.isdigit(), m_max) m_max = int(m_max)+1 except: m_max = 1 + prev_eps = {} + for label in servers_list.keys(): + prev_eps[label] = [] + + if isTvSeries == True: + clean_servers_list = True + while clean_servers_list == True: + doBreak = False + for label in servers_list.keys(): + for i in servers_list[label]: + q = re.sub('[^0-9]+', '-', i['quality']).replace('-','') + if len(q) == 0: + prev_eps[label].append(i) + servers_list[label].remove(i) + doBreak = True + break + if doBreak == True: + break + if doBreak == False: + clean_servers_list = False + + if common.DEV_DEBUG == True and Prefs["use_debug"]: + Log('================= servers_list-1-cleaned ===============') + Log(servers_list) + Log(prev_eps) + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('======== Fill missing %s - %s ========' % (min(m_min,1), max(len(servers_list[common.SERVER_PLACEHOLDER]),m_max))) + + # remap server list - this way its easier to iterate for tv-show episodes + c=0 + c_p=0 nos = 1-min(m_min,1) - if len(servers_list) > 0: + servers_list_new = [] + + if len(servers_list[common.SERVER_PLACEHOLDER]) > 0: for no in range(min(m_min,1), max(len(servers_list[common.SERVER_PLACEHOLDER]),m_max)): servers_list_new.append([]) servers_list_new[no-1+nos] = {} @@ -2592,20 +2627,19 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** skip_c = False try: sno = "%02d" % (no) if (no) <= 99 else "%03d" % (no) - if sno not in servers_list[common.SERVER_PLACEHOLDER][c]['quality']: - if common.DEV_DEBUG == True: + if sno not in servers_list[common.SERVER_PLACEHOLDER][c]['quality'] and isTvSeries == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('%s -- %s' % (sno, servers_list[common.SERVER_PLACEHOLDER][c]['quality'])) fillBlank = False skip_c = True q_lab = re.sub('[^0-9]+', '-', servers_list[common.SERVER_PLACEHOLDER][c]['quality']) else: - if common.DEV_DEBUG == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('%s - %s' % (sno, servers_list[common.SERVER_PLACEHOLDER][c]['quality'])) except Exception as e: - Log(e) - if common.DEV_DEBUG == True: + Log('Error -- %s' % e) + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('%s <-> %s' % (sno, servers_list[common.SERVER_PLACEHOLDER][c]['quality'])) - pass if fillBlank == True: for c2 in range(0,len(servers_list[label])): if servers_list[common.SERVER_PLACEHOLDER][c]['quality'] == servers_list[label][c2]['quality']: @@ -2621,10 +2655,10 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** str(int(q_lab)) except: q_lab = no - if common.DEV_DEBUG == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('q_lab : %s' % q_lab) servers_list_new[no-1+nos][label] = {'quality':q_lab,'loc':servers_list[label][c2]['loc'],'serverid':servers_list[label][c2]['serverid']} - if common.DEV_DEBUG == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('Fill- %s' % servers_list_new[no-1+nos][label]) break else: @@ -2634,7 +2668,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** if skip_c == False: c += 1 else: - if common.DEV_DEBUG == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('Fill-- %s' % servers_list_new[no-1+nos][common.SERVER_PLACEHOLDER]) q_lab = servers_list_new[no-1+nos][common.SERVER_PLACEHOLDER]['quality'] if '-' in q_lab: @@ -2643,11 +2677,28 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** c_p = c_p + int(q_lab[1])-int(q_lab[0]) except: c += 1 - + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log('================= servers_list_new-1B ===============') Log(servers_list_new) - + + for p in prev_eps[common.SERVER_PLACEHOLDER]: + item_to_insert = {} + for label in server_lab: + fillNone = True + for p2 in prev_eps[label]: + if p['quality'] == p2['quality']: + fillNone = False + item_to_insert[label]=p2 + break + if fillNone == True: + item_to_insert[label]={'loc': '', 'serverid': None, 'quality': p['quality']} + servers_list_new.insert(0,item_to_insert) + + if common.DEV_DEBUG == True and Prefs["use_debug"]: + Log('================= servers_list_new-1C ===============') + Log(servers_list_new) + if common.FMOVIES_HOSTS_UNPLAYABLE == True: for i in servers_list_new: for h_unp in common.FMOVIES_HOSTS_DISABLED: @@ -3340,32 +3391,46 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** c=0 c2=0 - for eps in servers_list_new: - if '-' in eps[server_lab[0]]['quality'] and verify2partcond(eps[server_lab[0]]['quality']): # 2 part episode condition - qual_i = max(int(eps[server_lab[0]]['quality'].split('-')[0])-eps_i,0) - eps_i += count2partcond(eps[server_lab[0]]['quality'])-1 - try: - if episodes_list[qual_i]['air_date'] == episodes_list[qual_i+1]['air_date']: - c2 += count2partcond(eps[server_lab[0]]['quality'])-1 - except: - pass - else: - try: - qual_i = max(int(eps[server_lab[0]]['quality'])-eps_i,0) + c2 - except: - qual_i = c_not_missing+1 + c2 - eps_i = eps_i-1 + c2 - + eps_c = 0 + for eps in servers_list_new: + qual_i = eps_c + # if '-' in eps[server_lab[0]]['quality'] and verify2partcond(eps[server_lab[0]]['quality']): # 2 part episode condition + # qual_i = max(int(eps[server_lab[0]]['quality'].split('-')[0])-eps_i,0) + # eps_i += count2partcond(eps[server_lab[0]]['quality'])-1 + # try: + # if episodes_list[qual_i]['air_date'] == episodes_list[qual_i+1]['air_date']: + # c2 += count2partcond(eps[server_lab[0]]['quality'])-1 + # except: + # pass + # else: + # try: + # qual_i = max(int(eps[server_lab[0]]['quality'])-eps_i,0) + c2 + # except: + # qual_i = c_not_missing+1 + c2 + # eps_i = eps_i-1 + c2 + + # try: + # if '-' in eps[server_lab[0]]['quality'] and episodes_list[qual_i]['name'] in eps[server_lab[0]]['quality'] and not verify2partcond(eps[server_lab[0]]['quality']): + # title_s = 'Ep:' + eps[server_lab[0]]['quality'] + # episode = eps[server_lab[0]]['quality'] + # else: + # title_s = 'Ep:' + eps[server_lab[0]]['quality'] + ' - ' + episodes_list[qual_i]['name'] + # episode = eps[server_lab[0]]['quality'] + # except: + # title_s = 'Ep:' + eps[server_lab[0]]['quality'] + # episode = eps[server_lab[0]]['quality'] + try: - if '-' in eps[server_lab[0]]['quality'] and episodes_list[qual_i]['name'] in eps[server_lab[0]]['quality'] and not verify2partcond(eps[server_lab[0]]['quality']): - title_s = 'Ep:' + eps[server_lab[0]]['quality'] - episode = eps[server_lab[0]]['quality'] - else: - title_s = 'Ep:' + eps[server_lab[0]]['quality'] + ' - ' + episodes_list[qual_i]['name'] - episode = eps[server_lab[0]]['quality'] - except: - title_s = 'Ep:' + eps[server_lab[0]]['quality'] episode = eps[server_lab[0]]['quality'] + title_s = 'Ep:%s - %s' % (episode,episodes_list[qual_i]['name']) + except: + try: + episode = eps[server_lab[0]]['quality'] + title_s = 'Ep:%s' % episode + except: + episode = qual_i + title_s = 'Ep:%s' % episode + try: desc = unicode('%s : %s' % (episodes_list[qual_i]['air_date'] , episodes_list[qual_i]['desc'])) except: @@ -3375,9 +3440,9 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** try: episodex = filter(lambda x: x.isdigit(), episode) - episode = episodex + episode = int(episodex) except: - pass + episode = '0' try: oc.add(DirectoryObject( @@ -3390,6 +3455,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** ) c_not_missing = qual_i c += 1 + eps_c += 1 except Exception as e: Log('ERROR init.py>EpisodeDetail>Tv1 %s, %s %s' % (e.args, title, c)) pass @@ -3428,6 +3494,7 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** c=0 episode = None + episodeN = 0 for eps in servers_list_new: try: episode = eps[server_lab[0]]['quality'] @@ -3435,10 +3502,13 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** try: episodex = filter(lambda x: x.isdigit(), episode) episode = episodex + episodeN = int(episode) except: - pass + if episodeN != 0: + episodeN += 1 + oc.add(DirectoryObject( - key = Callback(TvShowDetail, tvshow=title, title=title_s, url=url, servers_list_new=E(JSON.StringFromObject(servers_list_new[c])), server_lab=E(JSON.StringFromObject(server_lab)), summary='Episode Summary Not Available.\n ' + summary, thumb=thumb, art=art, year=year, rating=rating, duration=duration, genre=genre, directors=directors, roles=roles, serverts=serverts, session=session, season=SeasonN, episode=int(episode), imdb_id=imdb_id), + key = Callback(TvShowDetail, tvshow=title, title=title_s, url=url, servers_list_new=E(JSON.StringFromObject(servers_list_new[c])), server_lab=E(JSON.StringFromObject(server_lab)), summary='Episode Summary Not Available.\n ' + summary, thumb=thumb, art=art, year=year, rating=rating, duration=duration, genre=genre, directors=directors, roles=roles, serverts=serverts, session=session, season=SeasonN, episode=int(episodeN), imdb_id=imdb_id), title = title_s, summary = 'Episode Summary Not Available.\n ' + summary, art = art, @@ -3446,6 +3516,9 @@ def EpisodeDetail(title, url, thumb, session, dataEXS=None, dataEXSAnim=None, ** ) ) c += 1 + if episodeN == 0: + episodeN += 1 + except Exception as e: Log('ERROR init.py>EpisodeDetail>Tv2 %s, %s %s' % (e.args, title, c)) pass @@ -4276,7 +4349,7 @@ def ExtSources(title, url, summary, thumb, art, rating, duration, genre, directo if season != None and episode != None: watch_title = common.cleantitle.tvWatchTitle(tvshowtitlecleaned,season,episode,title) - if Prefs["use_debug"] and common.DEV_DEBUG == True: + if common.DEV_DEBUG == True and Prefs["use_debug"]: Log("---------=== DEV DEBUG START ===------------") Log("Length sources: %s" % len(internal_extSources)) for source in internal_extSources: diff --git a/Contents/Libraries/Shared/resources/lib/resolvers/host_gvideo.py b/Contents/Libraries/Shared/resources/lib/resolvers/host_gvideo.py index c308393..14a4eaa 100644 --- a/Contents/Libraries/Shared/resources/lib/resolvers/host_gvideo.py +++ b/Contents/Libraries/Shared/resources/lib/resolvers/host_gvideo.py @@ -429,6 +429,12 @@ def getFileLink(id, file_ext='.mp4', httpsskip=False): #print durl durl = client.request(durl, headers=headersD, cookie=cookieD, followredirect=True, output='geturl', limit='0') durl = durl.replace('?e=download','?e=file.mp4') + + try: + fs1 = client.getFileSize(durl, retry429=True) + fs = int(fs1) + except: + pass break except Exception as e: error = '%s' % e diff --git a/Contents/Libraries/Shared/resources/lib/sources/T3donlinefilms_ca.py b/Contents/Libraries/Shared/resources/lib/sources/T3donlinefilms_ca.py index f3d8b41..bc8b0f6 100644 --- a/Contents/Libraries/Shared/resources/lib/sources/T3donlinefilms_ca.py +++ b/Contents/Libraries/Shared/resources/lib/sources/T3donlinefilms_ca.py @@ -38,7 +38,7 @@ def __init__(self): self.base_link_alts = ['https://3donlinefilms.com','https://3dmoviesfullhd.com','https://www.freedocufilms.com'] self.base_link = self.base_link_alts[0] self.MainPageValidatingContent = '3D online Films: Watch 3D Movies on Virtual Reality Glasses or TV' - self.type_filter = ['movie', 'show', 'anime'] + self.type_filter = ['movie'] self.name = name self.disabled = False self.loggertxt = [] diff --git a/Contents/Libraries/Shared/resources/lib/sources/__init__.py b/Contents/Libraries/Shared/resources/lib/sources/__init__.py index 4a34c0a..b8cf965 100644 --- a/Contents/Libraries/Shared/resources/lib/sources/__init__.py +++ b/Contents/Libraries/Shared/resources/lib/sources/__init__.py @@ -119,7 +119,7 @@ def initProviders(self): self.providerInProcess.append('%s.py' % name) c = __import__(name, globals(), locals(), [], -1).source() log("Adding Provider %s : %s to Interface" % (c.info()['name'], c.info()['url']),name='providers') - self.providersCaller.append({'name':c.info()['name'], 'url':c.info()['url'], 'call':c}) + self.providersCaller.append({'name':c.info()['name'], 'url':c.info()['url'], 'call':c, 'types':c.type_filter}) self.providers.append(c.info()) self.providersTimer[c.info()['name']] = {} control.control_json[c.info()['name']] = {} @@ -129,7 +129,7 @@ def initProviders(self): try: c = __import__(name, globals(), locals(), [], -1).source() log("Adding Provider %s : %s to Interface" % (c.info()['name'], c.info()['url']),name='providers') - self.providersCaller.append({'name':c.info()['name'], 'url':c.info()['url'], 'call':c}) + self.providersCaller.append({'name':c.info()['name'], 'url':c.info()['url'], 'call':c, 'types':c.type_filter}) self.providers.append(c.info()) self.providersTimer[c.info()['name']] = {} control.control_json[c.info()['name']] = {} @@ -192,13 +192,14 @@ def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episod try: source_name = 'Unknow source (import error)' source_name = source['name'] - log(err='Queuing Search for Movie: %s (%s) in Provider %s' % (title,year,source_name)) - #thread_i = workers.Thread(self.getMovieSource, title, year, imdb, proxy_options, key, re.sub('_mv_tv$|_mv$|_tv$', '', source_name), source['call']) - thread_i = workers.Thread(self.getMovieSource, title, year, imdb, proxy_options, key, source_name, source['call']) - self.threads[key].append(thread_i) - self.threadSlots[key].append({'thread':thread_i, 'status':'idle', 'pos':pos, 'source':source_name}) - pos += 1 - #thread_i.start() + if content in source['types']: + log(err='Queuing Search for Movie: %s (%s) in Provider %s' % (title,year,source_name)) + thread_i = workers.Thread(self.getMovieSource, title, year, imdb, proxy_options, key, source_name, source['call']) + self.threads[key].append(thread_i) + self.threadSlots[key].append({'thread':thread_i, 'status':'idle', 'pos':pos, 'source':source_name}) + pos += 1 + else: + log(err='Content Movie: %s (%s) not supported in Provider %s' % (title,year,source_name)) except Exception as e: log(type='ERROR-CRITICAL', err='getSources %s - %s' % (source_name,e)) else: @@ -215,13 +216,14 @@ def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episod try: source_name = 'Unknow source (import error)' source_name = source['name'] - log(err='Queuing Search for Show: %s S%sE%s in Provider %s' % (tvshowtitle,season,episode,source_name)) - #thread_i = workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, proxy_options, key, re.sub('_mv_tv$|_mv$|_tv$', '', source_name), source['call']) - thread_i = workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, proxy_options, key, source_name, source['call']) - self.threads[key].append(thread_i) - self.threadSlots[key].append({'thread':thread_i, 'status':'idle', 'pos':pos, 'source':source_name}) - pos += 1 - #thread_i.start() + if content in source['types']: + log(err='Queuing Search for Show: %s S%sE%s in Provider %s' % (tvshowtitle,season,episode,source_name)) + thread_i = workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, proxy_options, key, source_name, source['call']) + self.threads[key].append(thread_i) + self.threadSlots[key].append({'thread':thread_i, 'status':'idle', 'pos':pos, 'source':source_name}) + pos += 1 + else: + log(err='Content Show: %s S%sE%s not supported in Provider %s' % (tvshowtitle,season,episode,source_name)) except Exception as e: log(type='ERROR-CRITICAL', err='getSources %s - %s' % (source_name,e)) @@ -229,16 +231,11 @@ def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episod thread_ex.start() self.executeThreadsStatus(key, thread_ex) - #sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict] - #sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel] - - #time.sleep(0.5) self.getSourcesAlive = False return self.sources except Exception as e: log(type='ERROR-CRITICAL', err='getSources - %s' % e) - # self.purgeSourcesKey(key=key) return self.sources diff --git a/Contents/Libraries/Shared/resources/lib/sources/gogoanime.py b/Contents/Libraries/Shared/resources/lib/sources/gogoanime.py index fa4b7d5..a42d899 100644 --- a/Contents/Libraries/Shared/resources/lib/sources/gogoanime.py +++ b/Contents/Libraries/Shared/resources/lib/sources/gogoanime.py @@ -41,7 +41,7 @@ def __init__(self): self.priority = 1 self.disabled = False self.language = ['en'] - self.type_filter = ['anime'] + self.type_filter = ['movie','show','anime'] self.domains = ['gogoanimemobile.com', 'gogoanimemobile.net', 'gogoanime.io'] self.base_link_alts = ['https://gogoanime.io','https://ww3.gogoanime.io','http://gogoanimemobile.com', 'http://gogoanimemobile.net'] self.base_link = self.base_link_alts[0] diff --git a/Contents/Libraries/Shared/resources/lib/sources/nineanime_ca.py b/Contents/Libraries/Shared/resources/lib/sources/nineanime_ca.py index e6d79db..eb815fa 100644 --- a/Contents/Libraries/Shared/resources/lib/sources/nineanime_ca.py +++ b/Contents/Libraries/Shared/resources/lib/sources/nineanime_ca.py @@ -56,7 +56,7 @@ def __init__(self): self.hash_menu_link = "/user/ajax/menu-bar" self.token_link = "/token" self.MainPageValidatingContent = ['9anime'] - self.type_filter = ['anime'] + self.type_filter = ['movie','show','anime'] self.ssl = False self.name = name self.headers = {}