def ChannelsMenu(url): oc = ObjectContainer(title2=SITETITLE) html = HTML.ElementFromURL(url) for item in html.xpath("//table[@class='tborder']//tbody/tr"): try: # Channel title channel = item.xpath( "./td[@class='alt1Active']/div[1]/a/strong/text()")[0] # Channel link link = item.xpath("./td[@class='alt1Active']/div[1]/a/@href")[0] if link.startswith("http") == False: link = SITEURL + link except: continue try: image = common.GetThumb(channel.lower()) except: continue if channel.lower() in common.GetSupportedChannels(): oc.add( DirectoryObject(key=Callback(ShowsMenu, url=link, title=channel), title=channel, thumb=image)) # If there are no channels, warn the user if len(oc) == 0: return ObjectContainer(header=SITETITLE, message=L('ChannelWarning')) return oc
def ChannelsMenu(url): oc = ObjectContainer(title2=SITETITLE) html = HTML.ElementFromURL(url) for item in html.xpath("//ul[@rel='Main Menu']//li//a"): try: # Channel title channel = item.xpath("text()")[0] # Channel link link = item.xpath("@href")[0] if link.startswith("http") == False: link = SITEURL + link #Log("Channel Link: " + link) except: continue try: image = common.GetThumb(channel.lower()) except: continue if channel.lower() in common.GetSupportedChannels(): oc.add(DirectoryObject(key=Callback(ShowsMenu, url=link, title=channel), title=channel, thumb=image)) # If there are no channels, warn the user if len(oc) == 0: return ObjectContainer(header=SITETITLE, message=L('ChannelWarning')) return oc
def OpenLoad_via_ID(query, dataIMDb=None, session=None, **kwargs): try: url = 'https://openload.co/f/%s' % query sources = common.host_openload.vid_link_from_id(query) except Exception as e: if Prefs['use_debug']: Log("ERROR tools.py>OpenLoad_via_ID 1: %s" % e) sources = None if sources == None or len(sources) == 0: return MC.message_container('OpenLoad via ID Error', 'OpenLoad via ID Error !') else: oc = None for source in sources: #Log(source) try: year = re.findall('.(\d{4}).', source['fileName'])[0] try: year = re.findall('(\d{4})', source['fileName'])[0] except: year = '0000' except: year = '0000' gen_play = (source['fileName'] + source['titleinfo'] + ' | (via Generic Playback)', None, common.GetThumb(source['poster'], session=session), source['params'], None, None, source['url'], source['quality'], source['fileName']) title, summary, thumb, params, duration, genres, videoUrl, videoRes, watch_title = gen_play art = thumb try: if dataIMDb != None: data = json.loads(D(dataIMDb)) title = data['Title'] year = data['Year'] watch_title = '%s (%s)' % (title, year) fileName = source['fileName'] source['fileName'] = watch_title summary = data['Plot'] art = thumb thumb = data['Poster'] genres = data['Genre'] try: duration = data['Runtime'].replace('min','').strip() except: duration = 'Not Available' rating = data['imdbRating'] roles = data['Actors'] directors = data['Director'] released = data['Released'] rated = data['Rated'] try: summary += '\n ' if str(duration) == 'Not Available': summary += 'Runtime: ' + str(duration) + '\n ' else: summary += 'Runtime: ' + str(duration) + ' min.' + '\n ' summary += 'Year: ' + year + '\n ' summary += 'Rated: ' + rated + '\n ' summary += 'Genre: ' + genres + '\n ' summary += 'Actors: ' + roles + '\n ' summary += 'Directors: ' + directors + '\n ' summary += 'IMDB rating: ' + rating + '\n ' summary += 'FileName: ' + fileName + '\n ' except: pass except Exception as e: Log(e) if oc == None: try: oc = ObjectContainer(title2 = source['fileName'] , no_cache=common.isForceNoCache()) except: oc = ObjectContainer(title2 = query , no_cache=common.isForceNoCache()) try: fs = source['fs'] fsBytes = int(fs) file_size = '%s GB' % str(round(float(fs)/common.TO_GB, 3)) except: fs = None fsBytes = 0 file_size = '? GB' status = common.GetEmoji(type=source['online'], session=session) title_msg = "%s %s| %s | %s | %s | %s | %s | %s" % (status, source['maininfo'], source['fileName'], source['rip'], source['quality'], file_size, source['source']+':'+source['subdomain'] if source['source']=='gvideo' else source['source'], source['provider']) if query not in RECENT_IMDB_SEARCHES.keys(): RECENT_IMDB_SEARCHES[query] = {'id':query, 'title':title, 'year':year, 'thumb':thumb, 'file_size':file_size, 'rip':source['rip'], 'quality':source['quality'], 'summary':summary, 'duration':duration, 'genres':genres, 'art':art, 'data':dataIMDb} try: oc.add(playback.CreateVideoObject(url, title_msg, summary, thumb, params, duration, genres, videoUrl, videoRes, watch_title, playDirect=True)) except Exception as e: Log("ERROR tools.py>OpenLoad_via_ID 2: %s" % e) try: libtype='movie' mode=common.DOWNLOAD_MODE[0] oc.add(DirectoryObject( key = Callback(downloadsmenu.AddToDownloadsListPre, title=title, purl=None, url=source['url'], durl=source['durl'], sub_url=source['sub_url'], summary=summary, thumb=thumb, year=year, fsBytes=None, fs=None, file_ext=source['file_ext'], quality=source['quality'], source=source['source'], source_meta={}, file_meta={}, type=libtype, vidtype=source['vidtype'].lower(), resumable=source['resumeDownload'], mode=mode, session=session, admin=True if mode==common.DOWNLOAD_MODE[0] else False, params=source['params'], riptype=source['rip'], provider=source['provider']), title = title_msg, summary = 'Adds the current video to %s List' % 'Download' if mode==common.DOWNLOAD_MODE[0] else 'Request', art = None, thumb = common.GetThumb(R('%s' % common.ICON_OTHERSOURCESDOWNLOAD if mode==common.DOWNLOAD_MODE[0] else common.ICON_REQUESTS), session=session) ) ) except Exception as e: Log("ERROR tools.py>OpenLoad_via_ID 3: %s" % e) oc.add(DirectoryObject(key = Callback(main.MainMenu), title = '<< Main Menu', thumb = R(common.ICON))) return oc
def DownloadingFilesMenu(title, uid, choice=None, session=None, status=None, confirm=False, refresh=0): oc = ObjectContainer(title1=title, no_cache=common.isForceNoCache()) if choice == None and uid in Dict: try: longstringObjs = JSON.ObjectFromString(D(Dict[uid])) #status = longstringObjs['status'] fileinfo = longstringObjs if status == common.DOWNLOAD_STATUS[1]: if uid in common.DOWNLOAD_STATS.keys(): fileinfo = common.DOWNLOAD_STATS[uid] else: pass #fileinfo = Dict[uid] try: eta = float(fileinfo['eta']) except: eta = '?' if eta == '?' or str(eta) == '0': eta_str = 'calculating time' elif eta < 0.1: eta_str = 'almost done' elif eta < 1: eta_str = '%02d sec. remaining' % int(int(float(eta) * 60.0)) elif eta > 60: eta_str = '%s hr. %02d min. %02d sec. remaining' % (int(int(eta)/60), (float(int(int(eta)/60))-float(int((float(eta)/60.0)/100)*100)), int(60 * (float(eta) - float(int(eta))))) else: eta_str = '%s min. %02d sec. remaining' % (int(eta), int(60 * (float(eta) - float(int(eta))))) i_title = '%s | %s | %s MB/s ~ %s MB/s ~ %s MB/s | %s - %s | %s' % (str(fileinfo['progress'])+'%', eta_str, str(fileinfo['chunk_speed']), str(fileinfo['avg_speed_curr']), str(fileinfo['avg_speed']), fileinfo['fs'], fileinfo['quality'], common.DOWNLOAD_ACTIONS_K[fileinfo['action']]) else: i_title = '%s | %s MB/s ~ %s MB/s ~ %s MB/s | %s - %s | %s' % (str(fileinfo['progress'])+'%', str(fileinfo['chunk_speed']), str(fileinfo['avg_speed_curr']), str(fileinfo['avg_speed']), fileinfo['fs'], fileinfo['quality'], common.DOWNLOAD_ACTIONS_K[fileinfo['action']]) i_title = unicode(i_title) oc.add(DirectoryObject( title = i_title, summary = i_title, key = Callback(MyMessage, title='Info', msg=i_title), thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) c = 0 for opt in common.DOWNLOAD_ACTIONS: if (status == common.DOWNLOAD_STATUS[0] and opt in [common.DOWNLOAD_ACTIONS[0], common.DOWNLOAD_ACTIONS[3], common.DOWNLOAD_ACTIONS[4]]) or (status == common.DOWNLOAD_STATUS[1] and opt in [common.DOWNLOAD_ACTIONS[0], common.DOWNLOAD_ACTIONS[1], common.DOWNLOAD_ACTIONS[2], common.DOWNLOAD_ACTIONS[3]]) or (status == common.DOWNLOAD_STATUS[3] and opt in [common.DOWNLOAD_ACTIONS[0], common.DOWNLOAD_ACTIONS[4]]) or (status == common.DOWNLOAD_STATUS[4] and opt in [common.DOWNLOAD_ACTIONS[0], common.DOWNLOAD_ACTIONS[4]]): if longstringObjs['action'] != opt and not (opt == common.DOWNLOAD_ACTIONS[2] and longstringObjs['action'] == common.DOWNLOAD_ACTIONS[4]) or status == common.DOWNLOAD_STATUS[3] and not(status == common.DOWNLOAD_STATUS[1] and longstringObjs['action'] in [common.DOWNLOAD_ACTIONS[2], common.DOWNLOAD_ACTIONS[4]]): opt_txt = opt if opt == common.DOWNLOAD_ACTIONS[3] or (opt == common.DOWNLOAD_ACTIONS[4] and longstringObjs['progress'] != '?' and float(longstringObjs['progress']) > 0): postpone_subtext = '(resumable download)' if longstringObjs['resumable']==True else '(non-resumable download)' opt_txt = '%s %s' % (opt,postpone_subtext) oc.add(DirectoryObject( title = opt_txt, summary = common.DOWNLOAD_ACTIONS_INFO[c], key = Callback(DownloadingFilesMenu, title=title, uid=uid, choice=opt, session=session, status=status), thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) c += 1 if longstringObjs['section_key'] == None: oc.add(DirectoryObject( title = 'Set Download Location', summary = '%s | Download path: %s' % (longstringObjs['section_title'], longstringObjs['section_path']), key = Callback(SetReqDownloadLocation, uid=longstringObjs['uid'], type=longstringObjs['type']), thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) else: oc.add(DirectoryObject( title = '%s | Download path: %s' % (longstringObjs['section_title'], longstringObjs['section_path']), summary = '%s | Download path: %s' % (longstringObjs['section_title'], longstringObjs['section_path']), key = Callback(MyMessage, title='Download Path', msg=longstringObjs['section_path']), thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) if longstringObjs['purl'] != None: oc.add(DirectoryObject( title = 'Video Page (Other Download Sources)', summary = 'Video Page: %s' % longstringObjs['title'], key = Callback(main.EpisodeDetail, title=longstringObjs['title'], url=longstringObjs['purl'], thumb=longstringObjs['thumb'], session = session), thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) else: oc.add(DirectoryObject( title = 'Video Page (Unavailable)', summary = 'Video Page: %s' % longstringObjs['title'], key = Callback(MyMessage, title='Video Page', msg='This Video Page is Unavailable'), thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) if status == common.DOWNLOAD_STATUS[2]: oc.add(DirectoryObject( title = 'Clear', key = Callback(DownloadingFilesMenu, title=longstringObjs['title'], uid=uid, choice=common.DOWNLOAD_ACTIONS[0], session=session, status=status), summary = 'Clear %s' % longstringObjs['title'], thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) oc.add(DirectoryObject( title = 'Refresh', key = Callback(DownloadingFilesMenu, title=title, uid=uid, choice=choice, session=session, status=status, confirm=confirm, refresh=int(refresh)+1), summary = 'Refresh Stats for %s' % longstringObjs['title'], thumb = common.GetThumb(R(common.ICON_REFRESH), session=session) ) ) except Exception as e: Log(e) return MC.message_container('Unavailable', 'Item removed or no longer available') return oc else: if AuthTools.CheckAdmin() == False: return MC.message_container('Admin Access Only', 'Only the Admin can perform this action !') if uid in Dict and choice != None: if choice == common.DOWNLOAD_ACTIONS[0] and confirm == False: oc = ObjectContainer(title1=unicode('Confirm ?'), no_cache=common.isForceNoCache()) oc.add(DirectoryObject(title = 'YES - Clear %s Entry' % title, key = Callback(DownloadingFilesMenu, title=title, uid=uid, choice=choice, session=session, status=status, confirm=True), thumb = R(common.ICON_OK))) oc.add(DirectoryObject(title = 'NO - Dont Clear %s Entry' % title, key = Callback(MyMessage, title='No Selected', msg='Return to previous screen'),thumb = R(common.ICON_NOTOK))) return oc longstringObjs = JSON.ObjectFromString(D(Dict[uid])) longstringObjs['action'] = choice status = longstringObjs['status'] doTrigger = True if status == common.DOWNLOAD_STATUS[0]: # Queued if choice == common.DOWNLOAD_ACTIONS[0]: if 'temp_file' in longstringObjs: filepath = longstringObjs['temp_file'] try: Core.storage.remove_data_item(filepath) except Exception as e: Log("=============ClearDownLoadSection Error============") Log(e) del Dict[uid] elif choice == common.DOWNLOAD_ACTIONS[4]: longstringObjs['timeAdded'] = time.time() #doTrigger = True EncTxt = E(JSON.StringFromObject(longstringObjs)) Dict[uid] = EncTxt elif status == common.DOWNLOAD_STATUS[1]: # Downloading uid = longstringObjs['uid'] if uid in common.DOWNLOAD_STATS.keys(): EncTxt = E(JSON.StringFromObject(longstringObjs)) Dict[uid] = EncTxt else: if uid in Dict.keys(): del Dict[uid] if uid in common.DOWNLOAD_TEMP.keys(): del common.DOWNLOAD_TEMP[uid] try: DOWNLOAD_TEMP = Dict['DOWNLOAD_TEMP'] DOWNLOAD_TEMP = JSON.ObjectFromString(D(DOWNLOAD_TEMP)) if uid in DOWNLOAD_TEMP.keys(): del DOWNLOAD_TEMP[uid] Dict['DOWNLOAD_TEMP'] = E(JSON.StringFromObject(DOWNLOAD_TEMP)) except: pass elif status == common.DOWNLOAD_STATUS[2]: # Completed uid = longstringObjs['uid'] if choice == common.DOWNLOAD_ACTIONS[0]: del Dict[uid] elif status == common.DOWNLOAD_STATUS[3]: # Failed #doTrigger = True if choice in [common.DOWNLOAD_ACTIONS[2], common.DOWNLOAD_ACTIONS[4]]: longstringObjs['status'] = common.DOWNLOAD_STATUS[0] EncTxt = E(JSON.StringFromObject(longstringObjs)) Dict[uid] = EncTxt elif choice == common.DOWNLOAD_ACTIONS[3]: longstringObjs['status'] = common.DOWNLOAD_STATUS[0] longstringObjs['timeAdded'] = time.time() + float(60*60*2) EncTxt = E(JSON.StringFromObject(longstringObjs)) Dict[uid] = EncTxt elif choice == common.DOWNLOAD_ACTIONS[0]: if 'temp_file' in longstringObjs: filepath = longstringObjs['temp_file'] try: Core.storage.remove_data_item(filepath) except Exception as e: Log("=============ClearDownLoadSection Error============") Log(e) del Dict[uid] elif status == common.DOWNLOAD_STATUS[4]: # Requested uid = longstringObjs['uid'] if choice == common.DOWNLOAD_ACTIONS[0]: del Dict[uid] elif choice == common.DOWNLOAD_ACTIONS[4]: if longstringObjs['section_key'] == None: return MC.message_container('Define Location', 'Please define Download Location first !') longstringObjs['status'] = common.DOWNLOAD_STATUS[0] longstringObjs['timeAdded'] = time.time() EncTxt = E(JSON.StringFromObject(longstringObjs)) Dict[uid] = EncTxt Dict.Save() if doTrigger == True: Thread.Create(download.trigger_que_run) time.sleep(2) if choice == common.DOWNLOAD_ACTIONS[3]: return MC.message_container('%s' % choice, '%s (by 2 hrs.) applied to %s' % (choice, title)) return MC.message_container('%s' % choice, '%s applied to %s' % (choice, title)) else: return MC.message_container('Unavailable', 'Item removed or no longer available')
def Downloads(title, session = None, status = None, refresh = 0, **kwargs): if not common.interface.isInitialized(): return MC.message_container("Please wait..", "Please wait a few seconds for the Interface to Load & Initialize plugins") oc = ObjectContainer(title1=title, no_cache=common.isForceNoCache()) if status == None: N_status = {} for dstatus in common.DOWNLOAD_STATUS: c = 0 for each in Dict: if 'Down5Split' in each: try: longstringObjs = JSON.ObjectFromString(D(Dict[each])) if longstringObjs['status'] == dstatus or dstatus == common.DOWNLOAD_STATUS[5]: c += 1 except Exception as e: Log('ERROR: Downloads >> %s' % e) N_status[dstatus] = c for statusx in common.DOWNLOAD_STATUS: oc.add(DirectoryObject( key = Callback(Downloads, title="%s Downloads" % statusx, status = statusx, session = session), title = '%s (%s)' % (statusx, str(N_status[statusx])) ) ) return oc items_to_del = [] doTrigger = False for each in Dict: if 'Down5Split' in each: try: longstringObjs = JSON.ObjectFromString(D(Dict[each])) if longstringObjs['status'] == status or status == common.DOWNLOAD_STATUS[5]: timestr = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(float(longstringObjs['timeAdded']))) key = None summary = longstringObjs['summary'] has_sub = False if longstringObjs['sub_url'] == None else True if status == common.DOWNLOAD_STATUS[0]: # Queued wtitle = '%s (%s) | %s | %s - %s | %s | %s - %s | %s | Subtitle:%s' % (longstringObjs['title'], longstringObjs['year'], longstringObjs['type'].title(), longstringObjs['fs'], longstringObjs['quality'], longstringObjs['source'], longstringObjs['status'], common.DOWNLOAD_ACTIONS_K[longstringObjs['action']], str(longstringObjs['progress'])+'%', common.GetEmoji(type=has_sub, mode='simple', session=session)) key = Callback(DownloadingFilesMenu, title=longstringObjs['title'], uid=longstringObjs['uid'], choice=None, session=session, status=status) elif status == common.DOWNLOAD_STATUS[1]: # Downloading if each not in common.DOWNLOAD_STATS.keys() and len(common.DOWNLOAD_STATS.keys()) < int(Prefs['download_connections']): longstringObjs['status'] = common.DOWNLOAD_STATUS[1] longstringObjs['action'] = common.DOWNLOAD_ACTIONS[4] Dict[each] = E(JSON.StringFromObject(longstringObjs)) #longstringObjs['status'] = common.DOWNLOAD_STATUS[1] #common.DOWNLOAD_STATS[each] = Dict[each] #doTrigger = True EncTxt = E(JSON.StringFromObject(longstringObjs)) Thread.Create(download.do_download, {}, file_meta_enc=EncTxt) elif each not in common.DOWNLOAD_STATS.keys(): longstringObjs['status'] = common.DOWNLOAD_STATUS[0] longstringObjs['action'] = common.DOWNLOAD_ACTIONS[4] Dict[each] = E(JSON.StringFromObject(longstringObjs)) doTrigger = True else: longstringObjs = common.DOWNLOAD_STATS[each] try: eta = float(longstringObjs['eta']) except: eta = '?' if eta == '?' or str(eta) == '0': eta_str = 'calculating time' elif eta < 0.1: eta_str = 'almost done' elif eta < 1: eta_str = '%02d sec. remaining' % int(int(float(eta) * 60.0)) elif eta > 60: eta_str = '%s hr. %02d min. %02d sec. remaining' % (int(int(eta)/60), (float(int(int(eta)/60))-float(int((float(eta)/60.0)/100)*100)), int(60 * (float(eta) - float(int(eta))))) else: eta_str = '%s min. %02d sec. remaining' % (int(eta), int(60 * (float(eta) - float(int(eta))))) wtitle = '%s (%s) | %s | %s - %s | %s | %s - %s | %s | %s MB/s ~ %s MB/s ~ %s MB/s | %s | Subtitle:%s' % (longstringObjs['title'], longstringObjs['year'], longstringObjs['type'].title(), longstringObjs['fs'], longstringObjs['quality'], longstringObjs['source'], longstringObjs['status'], common.DOWNLOAD_ACTIONS_K[longstringObjs['action']], str(longstringObjs['progress'])+'%', str(longstringObjs['chunk_speed']), str(longstringObjs['avg_speed_curr']), str(longstringObjs['avg_speed']), str(eta_str), common.GetEmoji(type=has_sub, mode='simple', session=session)) key = Callback(DownloadingFilesMenu, title=longstringObjs['title'], uid=longstringObjs['uid'], choice=None, session=session, status=status) elif status == common.DOWNLOAD_STATUS[2]: # Completed wtitle = '%s (%s) | %s | %s - %s | %s | %s - %s | %s | %s MB/s | Subtitle:%s' % (longstringObjs['title'], longstringObjs['year'], longstringObjs['type'].title(), longstringObjs['fs'], longstringObjs['quality'], longstringObjs['source'], longstringObjs['status'], common.DOWNLOAD_ACTIONS_K[longstringObjs['action']], str(longstringObjs['progress'])+'%', str(longstringObjs['avg_speed_curr']), common.GetEmoji(type=has_sub, mode='simple', session=session)) key = Callback(DownloadingFilesMenu, title=longstringObjs['title'], uid=longstringObjs['uid'], choice=None, session=session, status=status) elif status == common.DOWNLOAD_STATUS[3]: # Failed err = longstringObjs['last_error'] if longstringObjs['error'] == '' else longstringObjs['error'] wtitle = '%s (%s) | %s | %s - %s | %s | %s | %s - %s' % (longstringObjs['title'], longstringObjs['year'], longstringObjs['type'].title(), longstringObjs['fs'], longstringObjs['quality'], longstringObjs['source'], str(longstringObjs['progress'])+'%', longstringObjs['status'], err) key = Callback(DownloadingFilesMenu, title=longstringObjs['title'], uid=longstringObjs['uid'], choice=None, session=session, status=status) summary = '%s | %s' % (wtitle, summary) elif status == common.DOWNLOAD_STATUS[4]: # Requested if 'user' in longstringObjs.keys() and longstringObjs['user'] != None and AuthTools.CheckAdmin() == True: wtitle = '%s (%s) | %s | %s - %s | %s | %s (by %s) - %s | %s | %s MB/s | Subtitle:%s' % (longstringObjs['title'], longstringObjs['year'], longstringObjs['type'].title(), longstringObjs['fs'], longstringObjs['quality'], longstringObjs['source'], longstringObjs['status'], longstringObjs['user'], common.DOWNLOAD_ACTIONS_K[longstringObjs['action']], str(longstringObjs['progress'])+'%', str(longstringObjs['avg_speed_curr']), common.GetEmoji(type=has_sub, mode='simple', session=session)) else: wtitle = '%s (%s) | %s | %s - %s | %s | %s - %s | %s | %s MB/s | Subtitle:%s' % (longstringObjs['title'], longstringObjs['year'], longstringObjs['type'].title(), longstringObjs['fs'], longstringObjs['quality'], longstringObjs['source'], longstringObjs['status'], common.DOWNLOAD_ACTIONS_K[longstringObjs['action']], str(longstringObjs['progress'])+'%', str(longstringObjs['avg_speed_curr']), common.GetEmoji(type=has_sub, mode='simple', session=session)) key = Callback(DownloadingFilesMenu, title=longstringObjs['title'], uid=longstringObjs['uid'], choice=None, session=session, status=status) elif status == common.DOWNLOAD_STATUS[5]: # All if longstringObjs['status'] == common.DOWNLOAD_STATUS[1]: # Downloading if each not in common.DOWNLOAD_STATS.keys() and len(common.DOWNLOAD_STATS.keys()) < int(Prefs['download_connections']): longstringObjs['status'] = common.DOWNLOAD_STATUS[1] longstringObjs['action'] = common.DOWNLOAD_ACTIONS[4] Dict[each] = E(JSON.StringFromObject(longstringObjs)) EncTxt = E(JSON.StringFromObject(longstringObjs)) Thread.Create(download.do_download, {}, file_meta_enc=EncTxt) elif each not in common.DOWNLOAD_STATS.keys(): longstringObjs['status'] = common.DOWNLOAD_STATUS[0] longstringObjs['action'] = common.DOWNLOAD_ACTIONS[4] Dict[each] = E(JSON.StringFromObject(longstringObjs)) doTrigger = True else: longstringObjs = common.DOWNLOAD_STATS[each] try: eta = float(longstringObjs['eta']) except: eta = '?' if eta == '?' or str(eta) == '0': eta_str = 'calculating time' elif eta < 0.1: eta_str = 'almost done' elif eta < 1: eta_str = '%02d sec. remaining' % int(int(float(eta) * 60.0)) elif eta > 60: eta_str = '%s hr. %02d min. %02d sec. remaining' % (int(int(eta)/60), (float(int(int(eta)/60))-float(int((float(eta)/60.0)/100)*100)), int(60 * (float(eta) - float(int(eta))))) else: eta_str = '%s min. %02d sec. remaining' % (int(eta), int(60 * (float(eta) - float(int(eta))))) wtitle = '%s (%s) | %s | %s - %s | %s | %s - %s | %s | %s MB/s ~ %s MB/s ~ %s MB/s | %s | Subtitle:%s' % (longstringObjs['title'], longstringObjs['year'], longstringObjs['type'].title(), longstringObjs['fs'], longstringObjs['quality'], longstringObjs['source'], longstringObjs['status'], common.DOWNLOAD_ACTIONS_K[longstringObjs['action']], str(longstringObjs['progress'])+'%', str(longstringObjs['chunk_speed']), str(longstringObjs['avg_speed_curr']), str(longstringObjs['avg_speed']), str(eta_str), common.GetEmoji(type=has_sub, mode='simple', session=session)) else: wtitle = '%s (%s) | %s | %s - %s | %s | %s - %s | %s | %s MB/s | Subtitle:%s' % (longstringObjs['title'], longstringObjs['year'], longstringObjs['type'].title(), longstringObjs['fs'], longstringObjs['quality'], longstringObjs['source'], longstringObjs['status'], common.DOWNLOAD_ACTIONS_K[longstringObjs['action']], str(longstringObjs['progress'])+'%', str(longstringObjs['avg_speed_curr']), common.GetEmoji(type=has_sub, mode='simple', session=session)) key = Callback(DownloadingFilesMenu, title=longstringObjs['title'], uid=longstringObjs['uid'], choice=None, session=session, status=longstringObjs['status']) oc.add(DirectoryObject( title = wtitle, key = key, thumb = common.GetThumb(longstringObjs['thumb'], session=session), tagline = timestr, summary = summary ) ) except Exception as e: Log("==============Downloads==============") #Log(longstringObjs) Log(e) #Log(common.DOWNLOAD_STATS) items_to_del.append(each) if len(items_to_del) > 0: for each in items_to_del: if each in common.DOWNLOAD_STATS.keys(): del common.DOWNLOAD_STATS[each] try: encoded_str = Dict[each] decoded_str = D(encoded_str) longstringObjs = JSON.ObjectFromString(decoded_str) Log(longstringObjs) if 'temp_file' in longstringObjs: filepath = longstringObjs['temp_file'] try: Core.storage.remove_data_item(filepath) except Exception as e: Log("=============ClearDownLoadSection Error============") Log(e) Log("Deleting: %s" % longstringObjs['title']) del Dict[each] except: Log("Deleting: %s" % each) del Dict[each] Dict.Save() if doTrigger == True: Thread.Create(download.trigger_que_run) if len(oc) == 0: return MC.message_container(title, 'No %s section videos available' % status) oc.objects.sort(key=lambda obj: obj.tagline, reverse=True) if status != None: if status == common.DOWNLOAD_STATUS[3]: oc.add(DirectoryObject( title = 'Retry All Downloads', key = Callback(RetryFailedDownloads, session=session), summary = 'Retry Failed Downloads', thumb = common.GetThumb(R(common.ICON_REFRESH), session=session) ) ) elif status == common.DOWNLOAD_STATUS[1]: oc.add(DirectoryObject( title = 'Pause %s Downloads' % status, key = Callback(PauseDownloadingDownloads, session=session), summary = 'Pause %s Download Entries' % status, thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) oc.add(DirectoryObject( title = 'Postpone %s Downloads' % status, key = Callback(PostponeDownloadingDownloads, session=session), summary = 'Postpone %s Download Entries' % status, thumb = common.GetThumb(R(common.ICON_ENTER), session=session) ) ) oc.add(DirectoryObject( title = 'Refresh %s Downloads' % status, key = Callback(Downloads,title="%s Downloads" % status, status=status, session=session, refresh=int(refresh)+1), summary = 'Refresh %s Download Entries' % status, thumb = common.GetThumb(R(common.ICON_REFRESH), session=session) ) ) oc.add(DirectoryObject( title = 'Clear %s Downloads' % status, key = Callback(ClearDownLoadSection, status=status, session=session), summary = 'Remove %s Download Entries' % status, thumb = common.GetThumb(R(common.ICON_NOTOK), session=session) ) ) #oc.objects.sort(key=lambda obj: obj.title, reverse=False) return oc
def OpenLoad_via_ID(query, session=None, **kwargs): try: url = 'https://openload.co/f/%s' % query sources = common.host_openload.vid_link_from_id(query) except Exception as e: if Prefs['use_debug']: Log("ERROR tools.py>OpenLoad_via_ID 1: %s" % e) sources = None if sources == None or len(sources) == 0: return MC.message_container('OpenLoad via ID Error', 'OpenLoad via ID Error !') else: oc = None for source in sources: #Log(source) try: year = re.findall('(\d{4})', source['fileName'])[0] except: year = '0000' if oc == None: try: oc = ObjectContainer(title2=source['fileName'], no_cache=common.isForceNoCache()) except: oc = ObjectContainer(title2=query, no_cache=common.isForceNoCache()) gen_play = (source['fileName'] + source['titleinfo'] + ' | (via Generic Playback)', None, common.GetThumb(source['poster'], session=session), source['params'], None, None, source['url'], source['quality'], source['fileName']) title, summary, thumb, params, duration, genres, videoUrl, videoRes, watch_title = gen_play try: fs = source['fs'] fsBytes = int(fs) file_size = '%s GB' % str(round(float(fs) / common.TO_GB, 3)) except: fs = None fsBytes = 0 file_size = '? GB' status = common.GetEmoji(type=source['online'], session=session) title_msg = "%s %s| %s | %s | %s | %s | %s | %s" % ( status, source['maininfo'], source['fileName'], source['rip'], source['quality'], file_size, source['source'] + ':' + source['subdomain'] if source['source'] == 'gvideo' else source['source'], source['provider']) try: oc.add( playback.CreateVideoObject(url, title_msg, summary, thumb, params, duration, genres, videoUrl, videoRes, watch_title)) except Exception as e: Log("ERROR tools.py>OpenLoad_via_ID 2: %s" % e) try: libtype = 'movie' mode = common.DOWNLOAD_MODE[0] oc.add( DirectoryObject( key=Callback(downloadsmenu.AddToDownloadsListPre, title=watch_title, purl=None, url=source['url'], durl=source['durl'], sub_url=source['sub_url'], summary=summary, thumb=thumb, year=year, fsBytes=None, fs=None, file_ext=source['file_ext'], quality=source['quality'], source=source['source'], source_meta={}, file_meta={}, type=libtype, vidtype=source['vidtype'].lower(), resumable=source['resumeDownload'], mode=mode, session=session, admin=True if mode == common.DOWNLOAD_MODE[0] else False, params=source['params'], riptype=source['rip']), title=title_msg, summary='Adds the current video to %s List' % 'Download' if mode == common.DOWNLOAD_MODE[0] else 'Request', art=None, thumb=common.GetThumb(R( '%s' % common.ICON_OTHERSOURCESDOWNLOAD if mode == common.DOWNLOAD_MODE[0] else common.ICON_REQUESTS), session=session))) except Exception as e: Log("ERROR tools.py>OpenLoad_via_ID 3: %s" % e) return oc