def GetHostVideo(title, date, DateAdded, Quality, thumb, type, summary, directors, guest_stars, genres, duration, rating, season, index, content_rating, source_title, url, Host, HostPage=None, LinkType=None): if HostPage == None: (HostPage, LinkType) = GetHostPageURL(Host=Host, url=url) #Check For Real Host Host = HostPage.split('http://')[1].split('.')[0].capitalize() if Host == 'Www' or Host == 'Embed' or Host == 'Beta' or Host == 'Movie' or Host == 'Video': Host = HostPage.split('http://')[1].split('.')[1].capitalize() (path, request, ContentLength, NoError, VideoStreamLink) = ResumeMyDownload(Host=Host, HostPage=HostPage, url=url, LinkType=LinkType, title=title) if NoError == True: videotype = path.split('/')[-1].split('.')[1].partition('?')[0] hosts = LoadData(fp=WATCHIT_DATA, GetJson=3) numHosts = len(hosts) i = 1 jj = 0 while jj <= numHosts: try: if hosts[jj][i]['Path'] == "": hosts[jj][i]['Type'] = type hosts[jj][i]['DateAdded'] = DateAdded hosts[jj][i]['Quality'] = Quality hosts[jj][i]['Path'] = path hosts[jj][i]['Host'] = Host hosts[jj][i]['Title'] = title hosts[jj][i]['Summary'] = summary hosts[jj][i]['Genres'] = genres hosts[jj][i]['Directors'] = directors hosts[jj][i]['GuestStars'] = guest_stars hosts[jj][i]['Duration'] = duration hosts[jj][i]['Rating'] = rating hosts[jj][i]['Index'] = index hosts[jj][i]['Season'] = season hosts[jj][i]['ContentRating'] = content_rating hosts[jj][i]['SourceTitle'] = source_title hosts[jj][i]['Date'] = date hosts[jj][i]['ThumbURL'] = thumb hosts[jj][i]['VideoType'] = videotype hosts[jj][i]['VideoStreamLink'] = String.Quote(VideoStreamLink, usePlus=True) hosts[jj][i]['HostPage'] = String.Quote(HostPage, usePlus=True) hosts[jj][i]['URL'] = String.Quote(url, usePlus=True) hosts[jj][i]['LinkType'] = LinkType hosts[jj][i]['ContentLength'] = ContentLength break else: i += 1 jj += 1 except: hosts.append({i : {'Type': type, 'Path': path, 'Host': Host, 'DateAdded': DateAdded, 'Quality': Quality, 'ThumbURL': thumb, 'Title': title, 'Summary':summary, 'Genres': genres, 'Directors': directors, 'GuestStars':guest_stars, 'Duration': duration, 'Rating': rating, 'Index': index, 'Season': season, 'ContentRating': content_rating, 'SourceTitle': source_title, 'Date': date, 'VideoType': videotype, 'VideoStreamLink': VideoStreamLink, 'HostPage': HostPage, 'URL': url, 'LinkType': LinkType, 'ContentLength': ContentLength, 'FileCheckSize': '0', 'ResumePath': [], 'ResumeContentLength': '', 'ResumeCount': '0', 'Thread': '', 'FailedFileDeletion': '', 'isStitchingFiles': 'False', 'isConvertingFiles': 'False', 'isConvered': 'False', 'ConvertingTimeCode': '0'}}) break JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) return (path, request, NoError)
def convert_files(path, ConvertingHost, WATCHIT_DATA): hosts = LoadData(fp=WATCHIT_DATA, GetJson=3) c = Converter(Prefs['FFMPEG_PATH'], Prefs['FFPROBE_PATH']) info = c.probe(path) options = { 'format': 'mp4', 'audio': { 0: { 'map': 0, 'codec': 'aac', 'bitrate': 512, 'samplerate': 48000, 'channels': 2, 'language': 'eng' } }, 'video': { 'codec': 'h264', 'map': info.video.index, 'width': info.video.video_width, 'height': info.video.video_height, 'bitrate': info.format.bitrate, 'fps': info.video.video_fps } } conv = c.convert(path, path.replace(path[-4:], ".mp4"), options=options, timeout=None) i = 0 hosts[ConvertingHost - 1][ConvertingHost]['Duration'] = info.format.duration hosts[ConvertingHost - 1][ConvertingHost]['ConvertingTimeCode'] = 0 JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) for timecode in conv: if i != int(timecode): i = int(timecode) hosts[ConvertingHost - 1][ConvertingHost]['ConvertingTimeCode'] = timecode JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) hosts[ConvertingHost - 1][ConvertingHost]['Path'] = path.replace( path[-4:], ".mp4") hosts[ConvertingHost - 1][ConvertingHost]['isConverted'] = "True" JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) DeleteFile(path=path)
def MyDownloadThread(path, request): thread = threading.Thread(target=StartMyDownload, args=( path, request, )) #thread.setDaemon(True) threadList.append(thread) hosts = LoadData(fp=WATCHIT_DATA, GetJson=3) i = 1 for gethost in hosts: if gethost[i]['Path'] == path: gethost[i]['Thread'] = str(thread) break else: i += 1 JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) thread.start()
def MyConvertFilesThread(path, ConvertingHost, WATCHIT_DATA): thread = threading.Thread(target=convert_files, args=( path, ConvertingHost, WATCHIT_DATA, )) threadList.append(thread) hosts = LoadData(fp=WATCHIT_DATA, GetJson=3) i = 1 for gethost in hosts: if gethost[i]['Path'] == path: gethost[i]['Thread'] = str(thread) break else: i += 1 JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) thread.start()
def CheckFailedFileDeletions(): hosts = LoadData(fp=WATCHIT_DATA, GetJson=3) i = 1 for gethost in hosts: try: path = gethost[i]['FailedFileDeletion'] except: gethost[i].update({'FailedFileDeletion': ''}) path = "" if path != "": if os.path.isfile(path): try: os.remove(path) gethost[i]['FailedFileDeletion'] = "" except OSError: Log("Unable to remove file: %s" % path) else: Log("Error: %s file not found to remove." % path) #Fix any patch issues between plugin updates if dictionary has changed. try: gethost[i]['Type'] except: gethost[i].update({'Type': ''}) try: gethost[i]['DateAdded'] except: gethost[i].update({'DateAdded': ''}) try: gethost[i]['Quality'] except: gethost[i].update({'Quality': ''}) try: gethost[i]['Path'] except: gethost[i].update({'Path': ''}) try: gethost[i]['Host'] except: gethost[i].update({'Host': ''}) try: gethost[i]['Title'] except: gethost[i].update({'Title': ''}) try: gethost[i]['Summary'] except: gethost[i].update({'Summary': ''}) try: gethost[i]['Genres'] except: gethost[i].update({'Genres': ''}) try: gethost[i]['Directors'] except: gethost[i].update({'Directors': ''}) try: gethost[i]['GuestStars'] except: gethost[i].update({'GuestStars': ''}) try: gethost[i]['Duration'] except: gethost[i].update({'Duration': ''}) try: gethost[i]['Rating'] except: gethost[i].update({'Rating': '0.0'}) try: gethost[i]['Index'] except: gethost[i].update({'Index': '0'}) try: gethost[i]['Season'] except: gethost[i].update({'Season': '0'}) try: gethost[i]['ContentRating'] except: gethost[i].update({'ContentRating': ''}) try: gethost[i]['SourceTitle'] except: gethost[i].update({'SourceTitle': ''}) try: gethost[i]['Date'] except: gethost[i].update({'Date': ''}) try: gethost[i]['ThumbURL'] except: gethost[i].update({'ThumbURL': ''}) try: gethost[i]['VideoType'] except: gethost[i].update({'VideoType': ''}) try: gethost[i]['VideoStreamLink'] except: gethost[i].update({'VideoStreamLink': ''}) try: gethost[i]['HostPage'] except: gethost[i].update({'HostPage': ''}) try: gethost[i]['URL'] except: gethost[i].update({'URL': ''}) try: gethost[i]['LinkType'] except: gethost[i].update({'LinkType': ''}) try: gethost[i]['ContentLength'] except: gethost[i].update({'ContentLength': ''}) try: gethost[i]['FileCheckSize'] except: gethost[i].update({'FileCheckSize': '0'}) try: if type(gethost[i]['ResumePath']) != type(list()): ResumePath = gethost[i]['ResumePath'] gethost[i]['ResumePath'] = [ResumePath] except: gethost[i].update({'ResumePath': []}) try: gethost[i]['ResumeContentLength'] except: gethost[i].update({'ResumeContentLength': ''}) try: gethost[i]['ResumeCount'] except: gethost[i].update({'ResumeCount': '0'}) try: gethost[i]['Thread'] except: gethost[i].update({'Thread': ''}) try: gethost[i]['isStitchingFiles'] except: gethost[i].update({'isStitchingFiles': 'False'}) i += 1 JsonWrite(fp=WATCHIT_DATA, jsondata=hosts)
def GetHostVideo(title, date, DateAdded, Quality, thumb, type, summary, directors, guest_stars, genres, duration, rating, season, index, content_rating, source_title, url, Host): (HostPage, LinkType) = GetHostPageURL(Host=Host, url=url) #Check For Real Host Host = HostPage.split('http://')[1].split('.')[0].capitalize() if Host == 'Www' or Host == 'Embed' or Host == 'Beta' or Host == 'Movie' or Host == 'Video': Host = HostPage.split('http://')[1].split('.')[1].capitalize() (path, request, ContentLength, NoError, VideoStreamLink) = ResumeMyDownload(Host=Host, HostPage=HostPage, url=url, LinkType=LinkType, title=title) if NoError == True: videotype = path.split('/')[-1].split('.')[1] hosts = LoadData(fp=WATCHIT_DATA, GetJson=3) numHosts = len(hosts) i = 1 jj = 0 while jj <= numHosts: try: if hosts[jj][i]['Path'] == "": hosts[jj][i]['Type'] = type hosts[jj][i]['DateAdded'] = DateAdded hosts[jj][i]['Quality'] = Quality hosts[jj][i]['Path'] = path hosts[jj][i]['Host'] = Host hosts[jj][i]['Title'] = title hosts[jj][i]['Summary'] = summary hosts[jj][i]['Genres'] = genres hosts[jj][i]['Directors'] = directors hosts[jj][i]['GuestStars'] = guest_stars hosts[jj][i]['Duration'] = duration hosts[jj][i]['Rating'] = rating hosts[jj][i]['Index'] = index hosts[jj][i]['Season'] = season hosts[jj][i]['ContentRating'] = content_rating hosts[jj][i]['SourceTitle'] = source_title hosts[jj][i]['Date'] = date hosts[jj][i]['ThumbURL'] = thumb hosts[jj][i]['VideoType'] = videotype hosts[jj][i]['VideoStreamLink'] = String.Quote( VideoStreamLink, usePlus=True) hosts[jj][i]['HostPage'] = String.Quote(HostPage, usePlus=True) hosts[jj][i]['URL'] = String.Quote(url, usePlus=True) hosts[jj][i]['LinkType'] = LinkType hosts[jj][i]['ContentLength'] = ContentLength break else: i += 1 jj += 1 except: hosts.append({ i: { 'Type': type, 'Path': path, 'Host': Host, 'DateAdded': DateAdded, 'Quality': Quality, 'ThumbURL': thumb, 'Title': title, 'Summary': summary, 'Genres': genres, 'Directors': directors, 'GuestStars': guest_stars, 'Duration': duration, 'Rating': rating, 'Index': index, 'Season': season, 'ContentRating': content_rating, 'SourceTitle': source_title, 'Date': date, 'VideoType': videotype, 'VideoStreamLink': VideoStreamLink, 'HostPage': HostPage, 'URL': url, 'LinkType': LinkType, 'ContentLength': ContentLength, 'FileCheckSize': '0', 'ResumePath': [], 'ResumeContentLength': '', 'ResumeCount': '0', 'Thread': '', 'FailedFileDeletion': '', 'isStitchingFiles': 'False' } }) break JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) return (path, request, NoError)
def AutoCheckMyDownload(): global MyDownloadPath global MyDownloadRequest global stopStitching global ResumeParts global ResumePath global isAwake global stop i = 1 hosts = LoadData(fp=WATCHIT_DATA, GetJson=3) if isAwake == True: IamAwake = True else: isAwake = True IamAwake = False for gethost in hosts: if IamAwake == True: break path = gethost[i]['Path'] host = gethost[i]['Host'] videostreamlink = String.Unquote(gethost[i]['VideoStreamLink'], usePlus=True) HostPage = String.Unquote(gethost[i]['HostPage'], usePlus=True) url = String.Unquote(gethost[i]['URL'], usePlus=True) LinkType = gethost[i]['LinkType'] contentlength = gethost[i]['ContentLength'] FileCheckSize = gethost[i]['FileCheckSize'] resumepath = [] resumepath.extend(gethost[i]['ResumePath']) resumecontentlength = gethost[i]['ResumeContentLength'] resumecount = gethost[i]['ResumeCount'] isStitchingFiles = gethost[i]['isStitchingFiles'] if path != "": try: if isStitchingFiles == "True": part = os.stat(path).st_size percent = 100 * float(part) / float(contentlength) if percent == 100.00: gethost[i]['isStitchingFiles'] = "False" isStitchingFiles = "False" elif resumecontentlength == "": part = os.stat(path).st_size percent = 100 * float(part) / float(contentlength) LastTimeFileWrite = os.path.getmtime(path) LocalTime = time.time() ElapseTime = LocalTime - LastTimeFileWrite else: part = os.stat(path).st_size for getPaths in resumepath: part = part + os.stat(getPaths).st_size percent = 100 * float(part) / float(contentlength) if percent == 100.0: gethost[i]['isStitchingFiles'] = "True" isStitchingFiles = "True" gethost[i]['Path'] = path.replace('Part1.', '') gethost[i]['ResumePath'] = [] gethost[i]['ResumeContentLength'] = "" JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) ResumeParts = [path] + resumepath ResumePath = path.replace('Part1.', '') if stopStitching == None: stopStitching = StitchFilesTogether() else: LastTimeFileWrite = os.path.getmtime(resumepath[-1]) LocalTime = time.time() ElapseTime = LocalTime - LastTimeFileWrite except: Log("Error: %s file not found to play back." % path) part = 0 FileCheckSize = 0 percent = 0.0 ElapseTime = 120.0 isStitchingFiles = "False" gethost[i]['isStitchingFiles'] = "False" gethost[i]['ResumePath'] = [] gethost[i]['ResumeContentLength'] = "" if percent == 100.0 or isStitchingFiles == "True": pass elif ElapseTime >= 120.0 and int(FileCheckSize) == part: if stop == None: stop = CheckForDownload() (NullPath, NewDownloadRequest, ResumeContentLength, GoodLink, VideoStreamLink) = ResumeMyDownload( Host=host, HostPage=HostPage, url=url, LinkType=LinkType, startByte=str(part), ContentLength=contentlength) Log("TRYING TO RESUME DOWNLOAD FROM AUTUTORESUEM: " + str(GoodLink)) if int(ResumeContentLength) != int( contentlength) and GoodLink == True: if not "Part1." in path: os.renames( path, path.replace(DownloadPath, DownloadPath + 'Part1.')) gethost[i]['Path'] = path.replace( DownloadPath, DownloadPath + 'Part1.') NewDownloadPath = path.replace(DownloadPath, DownloadPath + 'Part2.') else: partnum = len(resumepath) + 2 NewDownloadPath = path.replace( DownloadPath + 'Part1.', DownloadPath + 'Part' + str(partnum) + '.') MyDownloadPath = NewDownloadPath gethost[i]['ResumePath'] = resumepath + [NewDownloadPath] gethost[i]['ResumeContentLength'] = str( ResumeContentLength) else: MyDownloadPath = path if GoodLink == True: MyDownloadRequest = NewDownloadRequest gethost[i]['FileCheckSize'] = "0" resumecount = int(resumecount) + 1 gethost[i]['ResumeCount'] = str(resumecount) JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) else: gethost[i]['FileCheckSize'] = str(part) JsonWrite(fp=WATCHIT_DATA, jsondata=hosts) i += 1 if IamAwake == False: isAwake = False