def init_search(title): global ds print("Searching videos. Please wait...") eel.navbar_control(False) eel.progress_search_fill_animation("search") ds = fetch_search(search(title, 1, "json", 15)) get_result(ds)
def core(): try: print("Initializing, please wait...") self.video = YouTube(url, on_progress_callback=self.on_progress) self.result = self.video.streams audio_size = self.get_audio_default().filesize print("Initializing done.") print("Fetching result...") for data in self.quality(): if data != False: print(data) eel.object_resolution( data.itag, data.type, row_idx, data.resolution, data.fps, data.itag, round(((data.filesize + audio_size) / math.pow(1 * 10, 6)), 2)) eel.disable_res_button() eel.object_resolution( self.get_audio_default().itag, self.get_audio_default().type, row_idx, self.get_audio_default().subtype, self.get_audio_default().abr.replace("kbps", ""), self.get_audio_default().itag, round(audio_size / math.pow(1 * 10, 6), 2)) eel.navbar_control(True) eel.progress_search_fill_animation("none") except pytube.exceptions.RegexMatchError as ex: print("Regex error. Try to re-initializing...") core() except HTTPError as ex: print("HTTP Error 404: Not found.")
def get_result(source): global datasource data = source["search_result"] eel.clearObj() for idx in data: datasource[idx["id"]] = { "id": idx["id"], "title": idx["title"], "channel": idx["channel"], "views": idx["views"], "thumbnails": idx["thumbnails"][4], "duration": idx["duration"], "link": idx["link"] } _id = idx["id"] _title = idx["title"] _channel = idx["channel"] _viewer = idx["views"] _imgurl = idx["thumbnails"][4] _duration = idx["duration"].replace(".", ":") # _imgurl = image_code_status(_imgurl) _link = idx["link"] eel.makeObj(_id, _title, _channel, _viewer, _imgurl, _link, _duration) print(datasource) eel.search_get_first_item() eel.enable_res_button() eel.navbar_control(True) eel.progress_search_fill_animation("none")
def app1_initTitle(title): global ds_1 print("Searching thumbnails. Please wait...") eel.navbar_control(False) eel.progress_search_fill_animation("search") ds_1 = app1_getThumbnails(search(title, 1, "json", 15)) app1_getUrlThumbnails(ds_1) eel.hide_welcome()
def get_result(source): global datasource data = "" if source != None: data = source["search_result"] eel.clearObj() eel.length_video_result(len(data)) if len(data) > 0: # eel.popup_result("hide") eel.text_search_result("hide") for idx in data: datasource[idx["id"]] = { "id": idx["id"], "title": idx["title"], "channel": idx["channel"], "views": idx["views"], "thumbnails": idx["thumbnails"][4], "duration": idx["duration"], "link": idx["link"] } _id = idx["id"] _title = idx["title"] _channel = idx["channel"] _viewer = idx["views"] _imgurl = idx["thumbnails"][4] _duration = idx["duration"].replace(".", ":") # _imgurl = image_code_status(_imgurl) _link = idx["link"] eel.makeObj(_id, _title, _channel, _viewer, _imgurl, _link, _duration) # print(datasource); print(f"{box.style(5,30,47)}Result:{box.end()}") [ print( f"[{Fore.BLUE}{idx+1}{Fore.RESET}] {Fore.GREEN}{id}{Fore.RESET} : [{Fore.YELLOW}{datasource[id]['duration']}{Fore.RESET}] {datasource[id]['title']}" ) for idx, id in enumerate(datasource) ] print(f"{Fore.GREEN}Ready...{Fore.RESET}") eel.search_get_first_item() eel.enable_res_button() else: print("Not found") # eel.popup_result("show") eel.text_search_result("show") print(f"{Fore.RED}Result not found{Fore.RESET}") eel.navbar_control(True) eel.progress_search_fill_animation("none") eel.text_search_focus()
def app1_getUrlThumbnails(source): data = source["search_result"] eel.app1_clearObj() eel.length_thumbnail_result(len(data)) if len(data) > 0: eel.text_search_result("hide") for idx in data: url = idx["thumbnails"][4] eel.app1_makeObj(url) else: print(f"{Fore.RED}Result not found{Fore.RESET}") eel.text_search_result("show") eel.navbar_control(True) eel.progress_search_fill_animation("none") eel.text_search_focus()
def core(): try: print("Initializing, please wait...") self.video = YouTube(url, on_progress_callback=self.on_progress) self.result = self.video.streams print(f"{Fore.GREEN}$ Initializing done.{Fore.RESET}") if len(self.result) > 0: audio_size = self.get_audio_default().filesize # --- give feedback progress & determine fetch via URL or SearchMode --- # if feedback.lower() == "panel": eel.progress_search_fill_animation("fetch_feedback") print("Fetching Video...") elif feedback.lower() == "url": print("Fetching URL...") eel.url_progress_feedback() # ---------------------------------------------------------------------- # obj_count = 0 def get_obj(): for data in self.quality(): if data != False: # --- get streams.result information --- # # print(data) # -------------------------------------- # eel.object_resolution( data.itag, data.type, row_idx, data.resolution, data.fps, data.itag, round(((data.filesize + audio_size) / math.pow(1 * 10, 6)), 2)) eel.disable_res_button() try: get_obj() except Exception as ex: print("Connection problem. Tryinga again...") obj_count = obj_count + 1 if obj_count <= 3: get_obj() if feedback.lower() == "panel": print( f"{box.style(5,32,40)}$ Video Fetching done.{box.end()}" ) elif feedback.lower() == "url": print( f"{box.style(5,32,40)}$ URL Fetching done.{box.end()}" ) eel.object_resolution( self.get_audio_default().itag, self.get_audio_default().type, row_idx, self.get_audio_default().subtype, self.get_audio_default().abr.replace("kbps", ""), self.get_audio_default().itag, round(audio_size / math.pow(1 * 10, 6), 2)) eel.btn_finish_fetch(row_idx) else: eel.btn_fetch_normal(row_idx) print( f"{Fore.RED}There are no result for a moments. Please try again later...{Fore.RESET}" ) eel.navbar_control(True) eel.progress_search_fill_animation("none") except pytube.exceptions.RegexMatchError as ex: print("Regex error. Try to re-initializing...") core() except HTTPError as ex: print("HTTP Error 404: Not found.")