File size: 1,290 Bytes
b49425d
6a71666
 
b49425d
 
6a71666
e5fc29e
 
 
 
 
 
b49425d
 
 
 
 
6a71666
e5fc29e
 
 
 
 
 
 
 
 
b49425d
 
 
 
6a71666
e5fc29e
 
 
 
 
 
 
 
b49425d
 
 
9a071f2
 
 
6a71666
e5fc29e
 
 
9a071f2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
from pytube import Playlist


def test_construct():
    ob = Playlist(
        'https://www.youtube.com/watch?v=m5q2GCsteQs&list='
        'PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw',
    )
    expected = 'https://www.youtube.com/' \
               'playlist?list=' \
               'PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw'

    assert ob.construct_playlist_url() == expected


def test_link_parse():
    ob = Playlist(
        'https://www.youtube.com/watch?v=m5q2GCsteQs&list='
        'PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw',
    )

    expected = [
        '/watch?v=m5q2GCsteQs',
        '/watch?v=5YK63cXyJ2Q',
        '/watch?v=Rzt4rUPFYD4',
    ]
    assert ob.parse_links() == expected


def test_populate():
    ob = Playlist(
        'https://www.youtube.com/watch?v=m5q2GCsteQs&list='
        'PL525f8ds9RvsXDl44X6Wwh9t3fCzFNApw',
    )
    expected = [
        'https://www.youtube.com/watch?v=m5q2GCsteQs',
        'https://www.youtube.com/watch?v=5YK63cXyJ2Q',
        'https://www.youtube.com/watch?v=Rzt4rUPFYD4',
    ]

    ob.populate_video_urls()
    assert ob.video_urls == expected


def test_download():
    ob = Playlist(
        'https://www.youtube.com/watch?v=lByG_AgKS9k&list='
        'PL525f8ds9RvuerPZ3bZygmNiYw2sP4BDk',
    )
    ob.download_all()