Example #1
0
    def threaded_download(self):

        try:
            if self.proxy.get() != '':
                proxy = {self.proxy.get().split(':')[0]: self.proxy.get()}
            else:
                proxy = None
            for search_stream in self.streams:
                if int(search_stream.itag) == int(self.stream.get()):
                    self.file_size = search_stream.filesize
                    break
            filename = download_youtube_video(self.text_url.get(), itag=self.stream.get(),
                                              output_path=self.output_path.get(),
                                              filename=self.filename_override.get()
                                              if self.filename_override.get() != '' else None,
                                              proxies=proxy, progress_callback=self.update_progress_bar)
            messagebox.showinfo('Download Complete!', 'Download Complete!\n%s' % filename)
        except PytubeError as e:
            messagebox.showerror('Something went wrong...', e)
        except RegexMatchError as e:
            messagebox.showerror('Something went wrong...', e)
        except Exception as e:
            messagebox.showerror('Something went wrong',
                                 'Something unknown went wrong. Is this a live stream? Wait until the stream ends.'
                                 '\n\n%s' % e)
        finally:
            self.btn_download['text'] = 'Download'
            self.btn_download.config(state=tk.NORMAL)
            self.btn_check_id.config(state=tk.NORMAL)
            self.btn_output_browse.config(state=tk.NORMAL)
            [radio_button.config(state=tk.NORMAL) for radio_button in self.radio_video_audio]
Example #2
0
def interactive_mode():
    print(get_header())
    while True:
        user = input('To Download Video/Audio Y/n: ')
        if user.lower() in ['yes', 'y']:
            url = input('Enter Url: ')
            form = input('Do you want to download video or audio: ')
            if form.lower() in ['video', 'v']:
                download_youtube_video(url, output_path='videos/')

            elif form.lower() in ['audio', 'a']:
                warn = input(
                    'Audio Downloads take longer Do you want to Continue Y/n: '
                )
                if warn.lower() in ['yes', 'y']:
                    download_youtube_video(url,
                                           audio_only=True,
                                           output_path='audio/')

                elif warn.lower() in ['no', 'n']:
                    vid = input('To Download Vid Y/n ')
                    if vid.lower() in ['yes', 'y']:
                        download_youtube_video(url, output_path='videos/')

                    elif vid.lower() in ['no', 'n']:
                        exit()
        if user.lower() in ['no', 'n']:
            print(get_footer())
            exit()
def run_one_thread(row):
    logger.info(row['video_url'])
    # print(row['video_url'])
    i = 0
    while True:
        try:
            if row['source'] == 'CrossMinds':
                logger.info('这是一个m3u8视频')
                # print('这是一个m3u8视频')
                m3u8.download(row['video_url'], row['title'])
            elif row['source'] == 'YouTube download':
                logger.info('这是一个youtube视频')
                # print('这是一个youtube视频')
                youtube.download_youtube_video(row['video_url'], row['title'])
            else:
                logger.info('这是个什么东西?')
            break
        except Exception as e:
            i = i + 1
            logger.warning(e)
            logger.warning(f"{row['title']},{row['video_url']}重试")
            if i > 10:
                break
            time.sleep(10)
Example #4
0
                        '--audio-only',
                        help='Download Audio Only',
                        action='store_true',
                        default=False)

    parsed_args = parser.parse_args()
    if parsed_args.proxy:
        parsed_args.proxy = {
            parsed_args.proxy.split(':')[0]: parsed_args.proxy
        }

    return parsed_args


if __name__ == '__main__':
    args = parse_args()
    if args.url:
        if args.list_streams:
            list_streams(args.url,
                         audio_only=args.audio_only,
                         proxies=args.proxy)
        else:
            download_youtube_video(args.url,
                                   itag=args.itag,
                                   audio_only=args.audio_only,
                                   output_path=args.output_path,
                                   filename=args.filename,
                                   proxies=args.proxy)
    else:
        interactive_mode()