63 def run(self) -> None:
65 @brief Download YouTube content
67 self.
main_controller.status_lbl.configure(text=
"Analysiere URL...", text_color=
"grey")
74 if re.search(
"&list=", s_url):
75 o_playlist = pytubefix.Playlist(s_url)
76 s_subfolder_name =
"/" + o_playlist.title
77 for video
in o_playlist.videos:
78 l_url.append(video.watch_url)
81 i_title_cnt = len(l_url)
82 for i, s_url
in enumerate(l_url, 1):
83 self.
main_controller.status_lbl.configure(text=
"Analysiere URL...", text_color=
"grey")
84 s_text = f
"Titel {i}/{i_title_cnt}: ..."
85 self.
main_controller.title_lbl.configure(text=s_text, text_color=
"orange")
89 s_titel = o_youtube.title[:35]
90 s_text = f
"Titel {i}/{i_title_cnt}: {s_titel}"
91 self.
main_controller.title_lbl.configure(text=s_text, text_color=
"orange")
94 self.
main_controller.status_lbl.configure(text=
"Ungültige URL!", text_color=
"red")
98 if i_choice == HIGH_RESOLUTION:
99 o_stream = o_youtube.streams.filter(progressive=
True, file_extension=
'mp4')\
100 .get_highest_resolution()
101 elif i_choice == LOW_RESOLUTION:
102 o_stream = o_youtube.streams.filter(progressive=
True, file_extension=
'mp4')\
103 .get_lowest_resolution()
104 elif i_choice == ONLY_AUDIO:
105 o_stream = o_youtube.streams.filter(only_audio=
True).first()
108 self.
main_controller.status_lbl.configure(text=
"Unerwarteter Fehler!", text_color=
"red")
110 self.
main_controller.status_lbl.configure(text=
"Download läuft...", text_color=
"grey")
111 o_stream.download(S_DOWNLOAD_FOLDER + s_subfolder_name, s_filename)
112 self.
main_controller.status_lbl.configure(text=
"Download abgeschlossen!", text_color=
"green")
114 if i_choice == ONLY_AUDIO:
115 self.
main_controller.status_lbl.configure(text=
"MP3 wird erstellt...", text_color=
"grey")
116 s_file_path_name = S_DOWNLOAD_FOLDER + s_subfolder_name +
"/" + o_stream.default_filename
117 audioclip = AudioFileClip(s_file_path_name)
118 audioclip.write_audiofile(s_file_path_name[:-1] +
"3")
120 os.remove(s_file_path_name)
121 self.
main_controller.status_lbl.configure(text=
"MP3 erstellt!", text_color=
"green")
122 except BaseException:
123 self.
main_controller.status_lbl.configure(text=
"Dieses Video kann nicht heruntergeladen werden!",
126 self.
main_controller.status_lbl.configure(text=
"Bitte Format angeben!", fg=
"red")
132 @brief Calculate process and update process bar
133 @param _stream : stream
134 @param _chunk : chunk
135 @param bytes_remaining : bytes remaining
142 f_actual_time = time.time()
147 if i_history_len < I_SPEED_AVERAGE_VALUES:
155 i_remaining_seconds = int(bytes_remaining / i_average_speed)
156 self.
main_controller.status_lbl.configure(text=f
'Download läuft... noch {i_remaining_seconds}sek', text_color=
"grey")
161 for _
in range(i_percent_diff):