Taylor Fox Dahlin commited on
Commit
b043411
·
unverified ·
1 Parent(s): e0d67e2

Feature/video keywords (#825)

Browse files

* Added keywords property and unit test.

Files changed (2) hide show
  1. pytube/__main__.py +7 -0
  2. tests/test_main.py +20 -0
pytube/__main__.py CHANGED
@@ -336,6 +336,13 @@ class YouTube:
336
  "author", "unknown"
337
  )
338
 
 
 
 
 
 
 
 
339
  @property
340
  def metadata(self) -> Optional[YouTubeMetadata]:
341
  """Get the metadata for the video.
 
336
  "author", "unknown"
337
  )
338
 
339
+ @property
340
+ def keywords(self) -> List[str]:
341
+ """Get the video keywords.
342
+ :rtype: List[str]
343
+ """
344
+ return self.player_response.get('videoDetails', {}).get('keywords', [])
345
+
346
  @property
347
  def metadata(self) -> Optional[YouTubeMetadata]:
348
  """Get the metadata for the video.
tests/test_main.py CHANGED
@@ -34,3 +34,23 @@ def test_video_unavailable(get):
34
  )
35
  with pytest.raises(VideoUnavailable):
36
  youtube.prefetch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  )
35
  with pytest.raises(VideoUnavailable):
36
  youtube.prefetch()
37
+
38
+
39
+ def test_video_keywords(cipher_signature):
40
+ expected = [
41
+ 'Rewind', 'Rewind 2019',
42
+ 'youtube rewind 2019', '#YouTubeRewind',
43
+ 'MrBeast', 'PewDiePie', 'James Charles',
44
+ 'Shane Dawson', 'CaseyNeistat', 'RiceGum',
45
+ 'Simone Giertz', 'JennaMarbles', 'Lilly Singh',
46
+ 'emma chamberlain', 'The Try Guys', 'Fortnite',
47
+ 'Minecraft', 'Roblox', 'Marshmello',
48
+ 'Garena Free Fire', 'GTA V', 'Lachlan',
49
+ 'Anaysa', 'jeffreestar', 'Noah Schnapp',
50
+ 'Jennelle Eliana', 'T-Series', 'Azzyland',
51
+ 'LazarBeam', 'Dude Perfect', 'David Dobrik',
52
+ 'KSI', 'NikkieTutorials', 'Kurzgesagt',
53
+ 'Jelly', 'Ariana Grande', 'Billie Eilish',
54
+ 'BLACKPINK', 'Year in Review'
55
+ ]
56
+ assert cipher_signature.keywords == expected