How to use the pytube.extract.video_id function in pytube

To help you get started, we’ve selected a few pytube examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nficano / pytube / tests / test_extract.py View on Github external
def test_extract_video_id():
    url = 'https://www.youtube.com/watch?v=9bZkp7q19f0'
    video_id = extract.video_id(url)
    assert video_id == '9bZkp7q19f0'
github YouTubeDownload / YouTubeDownload / qt_assets / tabs / downloader.py View on Github external
while self.__download_manager.thread_count > 1:
            self.sig_step.emit(self.id, 'Waiting for threads to clear...')
        thread_name = QThread.currentThread().objectName()
        thread_id = int(QThread.currentThreadId())
        self.sig_step.emit(self.id, f'{thread_id}: {thread_name} thread starting...')
        self.__download_manager.videos = []
        self.__download_manager.streams = []
        proxies = self.__download_manager.get_proxies()
        top_level_item_count = self.__download_manager.stream_tree.topLevelItemCount()
        for i in range(top_level_item_count):
            self.__download_manager.stream_tree.takeTopLevelItem(i)
        self.__download_manager.stream_tree.clear()
        self.__download_manager.streams_to_download = {}
        try:
            print('get video id')
            print(extract.video_id(self.__download_manager.url.text()))
            self.sig_step.emit(self.id, f'Loading video')
            loaded_url = YouTube(self.__download_manager.url.text(), proxies=proxies)
            self.sig_step.emit(self.id, f'Loaded video: {loaded_url.title}')
            self.sig_msg.emit(f'Found {loaded_url.title}')
            if self.__abort:
                self.sig_progress_status.emit(f'Aborted!')
                self.sig_done.emit(self.id)
                return
            self.__download_manager.videos.append(loaded_url)

        except RegexMatchError:
            print('playlist')
            if 'playlist' in self.__download_manager.url.text():
                regex_search(r'(?:list=|\/)([0-9A-Za-z_-]{11}).*', self.__download_manager.url.text(), group=1)
                loaded_url = Playlist(self.__download_manager.url.text())
                self.sig_msg.emit(f'Loaded playlist. Discovering videos...')
github YouTubeDownload / YouTubeDownload / utils.py View on Github external
def get_thumbnail_url(url=None, video=None, quality=THUMBNAIL_QAULITY_MED):
    if url is None and video is None:
        raise ValueError('You must provide either a url or YouTube object.')
    if video:
        return f'{video.thumbnail_url.rsplit("/", 1)[0]}/{quality}.jpg'
    if 'http' in url:
        video_id = get_video_id(url)
        return f'https://i.ytimg.com/vi/{video_id}/{quality}.jpg'
    return f'https://i.ytimg.com/vi/{url}/{quality}.jpg'
github ksharindam / quartz-browser-qt5 / quartz_browser / pytube / __main__.py View on Github external
# additional formats, but that doesn't appear to still be the case.

        self.vid_info = None      # content fetched by vid_info_url
        self.vid_info_url = None  # the url to vid info, parsed from watch html

        self.watch_html = None     # the html of /watch?v=
        self.embed_html = None
        self.player_config_args = None  # inline js in the html containing
        # streams
        self.age_restricted = None

        self.fmt_streams = []  # list of :class:`Stream ` instances
        self.caption_tracks = []

        # video_id part of /watch?v=
        self.video_id = extract.video_id(url)

        # https://www.youtube.com/watch?v=
        self.watch_url = extract.watch_url(self.video_id)

        self.embed_url = extract.embed_url(self.video_id)
        # A dictionary shared between all instances of :class:`Stream `
        # (Borg pattern).
        self.stream_monostate = {
            # user defined callback functions.
            'on_progress': on_progress_callback,
            'on_complete': on_complete_callback,
        }

        if proxies:
            install_proxy(proxies)
github nficano / pytube / pytube / __main__.py View on Github external
# additional formats, but that doesn't appear to still be the case.

        self.vid_info = None      # content fetched by vid_info_url
        self.vid_info_url = None  # the url to vid info, parsed from watch html

        self.watch_html = None     # the html of /watch?v=
        self.embed_html = None
        self.player_config_args = None  # inline js in the html containing
        # streams
        self.age_restricted = None

        self.fmt_streams = []  # list of :class:`Stream ` instances
        self.caption_tracks = []

        # video_id part of /watch?v=
        self.video_id = extract.video_id(url)

        # https://www.youtube.com/watch?v=
        self.watch_url = extract.watch_url(self.video_id)

        self.embed_url = extract.embed_url(self.video_id)
        # A dictionary shared between all instances of :class:`Stream `
        # (Borg pattern).
        self.stream_monostate = {
            # user defined callback functions.
            'on_progress': on_progress_callback,
            'on_complete': on_complete_callback,
        }

        if proxies:
            install_proxy(proxies)
github rols1 / Kodi-Addon-ARDundZDF / resources / lib / pytube / __main__.py View on Github external
# additional formats, but that doesn't appear to still be the case.

		self.vid_info = None      # content fetched by vid_info_url
		self.vid_info_url = None  # the url to vid info, parsed from watch html

		self.watch_html = None     # the html of /watch?v=
		self.embed_html = None
		self.player_config_args = None  # inline js in the html containing
		# streams
		self.age_restricted = None

		self.fmt_streams = []  # list of :class:`Stream ` instances
		self.caption_tracks = []

		# video_id part of /watch?v=
		self.video_id = extract.video_id(url)

		# https://www.youtube.com/watch?v=
		self.watch_url = extract.watch_url(self.video_id)

		self.embed_url = extract.embed_url(self.video_id)
		# A dictionary shared between all instances of :class:`Stream `
		# (Borg pattern).
		self.stream_monostate = {
			# user defined callback functions.
			'on_progress': on_progress_callback,
			'on_complete': on_complete_callback,
		}

		if proxies:
			install_proxy(proxies)