How to use pytube - 10 common examples

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 mraza007 / videodownloader / gui.py View on Github external
text = f'Codec: {stream.audio_codec}, ' \
                           f'ABR: {stream.abr} ' \
                           f'File Type: {stream.mime_type.split("/")[1]}, Size: {stream.filesize // 1024} KB'
                else:
                    if stream.video_codec is None:
                        continue
                    text = f'Res: {stream.resolution}, FPS: {stream.fps},' \
                           f' Video Codec: {stream.video_codec}, Audio Codec: {stream.audio_codec}, ' \
                           f'File Type: {stream.mime_type.split("/")[1]}, Size: {stream.filesize // 1024} KB'
                radio_button = tk.Radiobutton(self.frame, text=text, variable=self.stream, value=stream.itag)
                self.last_row += 1
                radio_button.grid(row=self.last_row, column=0, columnspan=4)
                self.stream_widgets.append(radio_button)
        except PytubeError as e:
            messagebox.showerror('Something went wrong...', e)
        except RegexMatchError as e:
            messagebox.showerror('Something went wrong...', e)
        finally:
            self.btn_check_id['text'] = 'Check Video'
            self.btn_check_id.config(state=tk.NORMAL)
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 nficano / pytube / tests / test_extract.py View on Github external
def test_extract_watch_url():
    video_id = '9bZkp7q19f0'
    watch_url = extract.watch_url(video_id)
    assert watch_url == 'https://youtube.com/watch?v=9bZkp7q19f0'
github nficano / pytube / tests / test_extract.py View on Github external
def test_js_url(cipher_signature):
    expected = 'https://youtube.com/yts/jsbin/player-vflOdyxa4/en_US/base.js'
    result = extract.js_url(cipher_signature.watch_html)
    assert expected == result
github nficano / pytube / tests / test_request.py View on Github external
def test_get(mock_urlopen):
    response = mock.Mock()
    response.read.return_value = ''.encode('utf-8')
    mock_urlopen.return_value = response
    response = request.get('fakeassurl.gov')
    assert response == ''
github nficano / pytube / tests / test_streams.py View on Github external
def test_filesize(cipher_signature, mocker):
    mocker.patch.object(request, 'get')
    request.get.return_value = {'content-length': '6796391'}
    assert cipher_signature.streams.first().filesize == 6796391
github nficano / pytube / tests / test_streams.py View on Github external
def test_filesize(cipher_signature, mocker):
    mocker.patch.object(request, 'get')
    request.get.return_value = {'content-length': '6796391'}
    assert cipher_signature.streams.first().filesize == 6796391
github nficano / pytube / tests / test_extract.py View on Github external
def test_age_restricted(age_restricted):
    assert extract.is_age_restricted(age_restricted['watch_html'])
github nficano / pytube / tests / test_extract.py View on Github external
def test_get_vid_desc(cipher_signature):
    expected = "PSY - DADDY(feat. CL of 2NE1) M/V @ https://youtu.be/FrG4TEcSuRgPSY - 나팔바지(NAPAL BAJI) M/V @ https://youtu.be/tF27TNC_4pcPSY - 7TH ALBUM '칠집싸이다' on iTunes @ http://smarturl.it/PSY_7THALBUMPSY - GANGNAM STYLE(강남스타일) on iTunes @ http://smarturl.it/PsyGangnam#PSY #싸이 #GANGNAMSTYLE #강남스타일More about PSY@http://www.psypark.com/http://www.youtube.com/officialpsyhttp://www.facebook.com/officialpsyhttp://twitter.com/psy_oppahttps://www.instagram.com/42psy42http://iTunes.com/PSYhttp://sptfy.com/PSYhttp://weibo.com/psyoppahttp://twitter.com/ygent_official"  # noqa
    assert extract.get_vid_descr(cipher_signature.watch_html) == expected
github nficano / pytube / tests / test_extract.py View on Github external
def test_info_url(cipher_signature):
    video_info_url = extract.video_info_url(
        video_id=cipher_signature.video_id,
        watch_url=cipher_signature.watch_url,
        watch_html=cipher_signature.watch_html,
        embed_html='',
        age_restricted=False,
    )
    expected = (
        'https://youtube.com/get_video_info?video_id=9bZkp7q19f0&el=%24el'
        '&ps=default&eurl=https%253A%2F%2Fyoutube.com%2Fwatch%253Fv%'
        '253D9bZkp7q19f0&hl=en_US&t=%252C%2522t%2522%253A%25221%2522'
    )
    assert video_info_url == expected