def run(self): final_url = '' try: final_url = get_yt_url(self.url, self.quality, self.path, self.loger, mode='a+v') self.gotlink.emit(final_url, self.nm) try: if not self.nm: req = urllib.request.Request( self.url, data=None, headers={'User-Agent': 'Mozilla/5.0'}) f = urllib.request.urlopen(req) content = f.read().decode('utf-8') soup = BeautifulSoup(content, 'lxml') title = soup.title.text.replace(' - YouTube', '').strip() logger.info(title) ui.epn_name_in_list = title except Exception as e: print(e, '---2877---') except Exception as e: print(e, '--2865--')
def run(self): finalUrl = "" try: if self.epn_type == 'yt': finalUrl = get_yt_url(self.final, self.quality, self.yt_path, logger, mode='a+v') elif self.epn_type == 'addons': finalUrl = ui.site_var.getFinalUrl(self.name, self.epn, self.mirrorNo, self.quality) elif self.epn_type == 'type_one': finalUrl = ui.site_var.getFinalUrl(self.siteName, self.name, self.epn, self.mirrorNo, self.category, self.quality) elif self.epn_type == 'type_two': finalUrl = ui.site_var.getFinalUrl(self.siteName, self.name, self.epn, self.mirrorNo, self.quality) elif self.epn_type == 'offline': finalUrl = ui.epn_return(self.row, mode=self.mode) elif self.epn_type == 'list': mytuple = ui.site_var.getEpnList(self.name, self.opt, self.depth_list, self.extra_info, self.siteName, self.category) mylist = [] for i in mytuple: mylist.append(i) mylist.append(self.name) mylist.append(self.extra_info) mylist.append(self.siteName) mylist.append(self.opt) mylist.append(self.row) except Exception as err: print(err, '--707--') if self.epn_type != 'list': ui.epnfound_final_link = finalUrl if not isinstance(finalUrl, list): if self.epn_type == 'offline': self.get_offline_signal.emit(finalUrl, self.row) elif self.epn_type == 'list': self.get_listfound_signal.emit(mylist) else: self.get_epn_signal.emit(finalUrl, str(self.row)) else: if self.epn_type == 'offline': self.get_offline_signal_list.emit(finalUrl, self.row) else: self.get_epn_signal_list.emit(finalUrl, str(self.row))
def clicked_link(self,link): final_url = '' url = link self.epn_name_in_list = self.title() print(url,'clicked_link') if 'youtube.com/watch?v=' in url: if self.ui.mpvplayer_val.processId() > 0: self.ui.mpvplayer_val.kill() final_url = get_yt_url(url,self.ui.quality_val,self.ui.ytdl_path,self.ui.logger) if final_url: print(final_url,'--youtube--') self.ui.watchDirectly(final_url,self.epn_name_in_list,'no') self.ui.tab_5.show() self.ui.frame1.show() self.ui.tab_2.setMaximumWidth(self.ui.width_allowed+50)
def download(self, url, option, copy_summary=None): if option.lower() == 'play with kawaii-player': final_url = '' self.ui.epn_name_in_list = self.title_page self.ui.logger.info(self.ui.epn_name_in_list) if self.ui.mpvplayer_val.processId() > 0: self.ui.mpvplayer_val.kill() final_url = get_yt_url(url, self.ui.quality_val, self.ui.ytdl_path, self.ui.logger) if final_url: self.ui.watchDirectly(final_url, self.ui.epn_name_in_list, 'no') self.ui.tab_5.show() self.ui.frame1.show() self.ui.tab_2.setMaximumWidth(400) elif option.lower() == 'add as local playlist': self.get_playlist = True if self.playlist_dict: self.ui.logger.info(self.get_playlist, '=get_playlist') self.add_playlist(self.playlist_name) elif option.lower() == 'download': if self.ui.quality_val == 'sd480p': txt = "Video can't be saved in 480p, Saving in either HD or SD" send_notification(txt) quality = 'hd' else: quality = self.ui.quality_val finalUrl = get_yt_url(url, quality, self.ui.ytdl_path, self.ui.logger) finalUrl = finalUrl.replace('\n', '') title = self.title_page + '.mp4' title = title.replace('"', '') title = title.replace('/', '-') if os.path.exists(self.ui.default_download_location): title = os.path.join(self.ui.default_download_location, title) else: title = os.path.join(self.ui.tmp_download_folder, title) command = wget_string(finalUrl, title, self.ui.get_fetch_library) print(command) self.ui.infoWget(command, 0) elif option.lower() == 'get subtitle (if available)': self.ui.epn_name_in_list = self.title_page self.ui.logger.info(self.ui.epn_name_in_list) get_yt_sub(url, self.ui.epn_name_in_list, self.yt_sub_folder, self.ui.tmp_download_folder, self.ui.ytdl_path, self.ui.logger) elif option.lower() == 'queue item': file_path = os.path.join(self.home, 'Playlists', 'Queue') if not os.path.exists(file_path): f = open(file_path, 'w') f.close() if not self.ui.queue_url_list: self.ui.list6.clear() title = self.title_page.replace('/', '-') if title.startswith('.'): title = title[1:] r = title + ' ' + url + ' ' + 'NONE' self.ui.queue_url_list.append(r) self.ui.list6.addItem(title) print(self.ui.queue_url_list) write_files(file_path, r, line_by_line=True) elif option.lower() == 'season episode link': if self.site != "Music" and self.site != "PlayLists": self.ui.getTvdbEpnInfo(url) elif option.lower() == 'artist link' or option.lower( ) == 'series link': r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) self.ui.posterfound_new(name=nm, site=self.site, url=url, direct_url=True, copy_summary=True, copy_poster=True, copy_fanart=True) elif option.lower() == 'copy summary': self.ui.copySummary(copy_sum=copy_summary) else: if not url: url = self.media_url print(url, self.media_url, '--media--url--') if url: t_content = ccurl(url + '#' + '-I') if 'image/jpeg' in t_content and not 'Location:' in t_content: pass elif 'image/jpeg' in t_content and 'Location:' in t_content: m = re.findall('Location: [^\n]*', t_content) found = re.sub('Location: |\r', '', m[0]) url = found elif self.media_url: url = self.media_url else: return 0 if option.lower() == "download as fanart": r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) print(option, '----') self.ui.posterfound_new(name=nm, site=self.site, url=url, direct_url=True, copy_summary=False, copy_poster=False, copy_fanart=True) elif option.lower() == "download as cover": r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) self.ui.posterfound_new(name=nm, site=self.site, url=url, direct_url=True, copy_summary=False, copy_poster=True, copy_fanart=False)
def download(self, url, option): if option.lower() == 'play with kawaii-player': final_url = '' self.ui.epn_name_in_list = self.title_page print(self.ui.epn_name_in_list) if self.ui.mpvplayer_val.processId() > 0: self.ui.mpvplayer_val.kill() self.ui.mpvplayer_started = False if 'youtube.com' in url.toString() or 'ytimg.com' in url.toString( ): final_url = url.toString() else: final_url = 'ytdl:' + url.toString() self.ui.get_final_link(final_url, self.ui.quality_val, self.ui.ytdl_path, self.ui.logger, self.ui.epn_name_in_list, self.hdr) elif option.lower() == 'add as local playlist': self.get_playlist = True if self.playlist_dict: print(self.get_playlist, '=get_playlist') self.add_playlist(self.playlist_name) elif option.lower() == 'download': if self.ui.quality_val == 'sd480p': txt = "Video can't be saved in 480p, Saving in either HD or SD" send_notification(txt) quality = 'hd' else: quality = self.ui.quality_val finalUrl = get_yt_url(url.toString(), quality, self.ui.ytdl_path, self.ui.logger, mode='offline') finalUrl = finalUrl.replace('\n', '') title = self.title_page + '.mp4' title = title.replace('"', '') title = title.replace('/', '-') if os.path.exists(self.ui.default_download_location): title = os.path.join(self.ui.default_download_location, title) else: title = os.path.join(self.ui.tmp_download_folder, title) command = wget_string(finalUrl, title, self.ui.get_fetch_library) print(command) self.ui.infoWget(command, 0) elif option.lower() == 'get subtitle (if available)': self.ui.epn_name_in_list = self.title_page print(self.ui.epn_name_in_list) get_yt_sub(url.toString(), self.ui.epn_name_in_list, self.yt_sub_folder, self.ui.tmp_download_folder, self.ui.ytdl_path, self.ui.logger) elif option.lower() == 'queue item': file_path = os.path.join(self.home, 'Playlists', 'Queue') if not os.path.exists(file_path): f = open(file_path, 'w') f.close() if not self.ui.queue_url_list: self.ui.list6.clear() title = self.title_page.replace('/', '-') if title.startswith('.'): title = title[1:] r = title + ' ' + url.toString() + ' ' + 'NONE' self.ui.queue_url_list.append(r) self.ui.list6.addItem(title) print(self.ui.queue_url_list) write_files(file_path, r, line_by_line=True) elif option.lower() == 'season episode link': if self.site != "Music" and self.site != "PlayLists": my_copy = self.ui.epn_arr_list.copy() r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) self.ui.metaengine.getTvdbEpnInfo(url.toString(), site=self.site, epn_arr=my_copy, name=nm, row=r) elif (option.lower() == 'artist link' or option.lower() == 'series link' or option.lower() == 'series/movie link'): url = url.toString() r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) self.ui.posterfound_new(name=nm, site=self.site, url=url, direct_url=True, copy_summary=True, copy_poster=True, copy_fanart=True) else: url = url.toString() if url: t_content = ccurl(url, curl_opt='-I') if 'image/jpeg' in t_content and not 'Location:' in t_content: pass elif 'image/jpeg' in t_content and 'Location:' in t_content: m = re.findall('Location: [^\n]*', t_content) found = re.sub('Location: |\r', '', m[0]) url = found elif not self.img_url.isEmpty(): url = self.img_url.toString() else: return 0 if '#' in url: url = url.split('#')[0] if option.lower() == "download as fanart": r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) print(option, '----') self.ui.posterfound_new(name=nm, site=self.site, url=url, direct_url=True, copy_summary=False, copy_poster=False, copy_fanart=True) elif option.lower() == "download as cover": r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) self.ui.posterfound_new(name=nm, site=self.site, url=url, direct_url=True, copy_summary=False, copy_poster=True, copy_fanart=False)
def download(self, url,option): if option.lower() == 'play with animewatch': final_url = '' self.ui.epn_name_in_list = self.title_page print(self.ui.epn_name_in_list) if self.ui.mpvplayer_val.processId() > 0: self.ui.mpvplayer_val.kill() final_url = get_yt_url(url.toString(),self.ui.quality_val,self.ui.ytdl_path,self.ui.logger) if final_url: self.ui.watchDirectly(final_url,self.ui.epn_name_in_list,'no') self.ui.tab_5.show() self.ui.frame1.show() self.ui.tab_2.setMaximumWidth(self.ui.width_allowed+50) elif option.lower() == 'add as local playlist': self.get_playlist = True if self.playlist_dict: print(self.get_playlist,'=get_playlist') self.add_playlist(self.playlist_name) elif option.lower() == 'download': if self.ui.quality_val == 'sd480p': txt = "Video can't be saved in 480p, Saving in either HD or SD" send_notification(txt) quality = 'hd' else: quality = self.ui.quality_val finalUrl = get_yt_url(url.toString(),quality,self.ui.ytdl_path,self.ui.logger) finalUrl = finalUrl.replace('\n','') title = self.title_page+'.mp4' title = title.replace('"','') title = title.replace('/','-') if os.path.exists(self.ui.default_download_location): title = os.path.join(self.ui.default_download_location,title) else: title = os.path.join(self.ui.tmp_download_folder,title) command = wget_string(finalUrl,title,self.ui.get_fetch_library) print (command) self.ui.infoWget(command,0) elif option.lower() == 'get subtitle (if available)': self.ui.epn_name_in_list = self.title_page print(self.ui.epn_name_in_list) get_yt_sub(url.toString(),self.ui.epn_name_in_list, self.yt_sub_folder,self.ui.tmp_download_folder, self.ui.ytdl_path,self.ui.logger) elif option.lower() == 'queue item': file_path = os.path.join(self.home,'Playlists','Queue') if not os.path.exists(file_path): f = open(file_path,'w') f.close() if not self.ui.queue_url_list: self.ui.list6.clear() title = self.title_page.replace('/','-') if title.startswith('.'): title = title[1:] r = title + ' '+url.toString()+' '+'NONE' self.ui.queue_url_list.append(r) self.ui.list6.addItem(title) print (self.ui.queue_url_list) write_files(file_path,r,line_by_line=True) elif option.lower() == 'season episode link': if self.site != "Music" and self.site != "PlayLists": self.ui.getTvdbEpnInfo(url.toString()) elif option.lower() == 'artist link' or option.lower() == 'series link': url = url.toString() r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) self.ui.posterfound_new( name=nm,site=self.site,url=url,direct_url=True, copy_summary=True,copy_poster=True,copy_fanart=True) else: url = url.toString() if url: t_content = ccurl(url+'#'+'-I') if 'image/jpeg' in t_content and not 'Location:' in t_content: pass elif 'image/jpeg' in t_content and 'Location:' in t_content: m = re.findall('Location: [^\n]*',t_content) found = re.sub('Location: |\r','',m[0]) url = found elif not self.img_url.isEmpty(): url = self.img_url.toString() else: return 0 if option.lower() == "download as fanart": r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) print(option,'----') self.ui.posterfound_new( name=nm,site=self.site,url=url,direct_url=True, copy_summary=False,copy_poster=False,copy_fanart=True) elif option.lower() == "download as cover": r = self.ui.list1.currentRow() nm = self.ui.get_title_name(r) self.ui.posterfound_new( name=nm,site=self.site,url=url,direct_url=True, copy_summary=False,copy_poster=True,copy_fanart=False)