mps-youtube / pafy

Python library to download YouTube content and retrieve metadata
1.39k stars 313 forks source link

Add support for live videos #193

Open gornostal opened 6 years ago

gornostal commented 6 years ago

Hi

When I enter live video URL I get the error below. Is this expected? Does pafy support live videos?

>>> pafy.__version__
'0.5.3.1'
>>> pafy.new("https://www.youtube.com/watch?v=461zegf_Gv4")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/site-packages/pafy/pafy.py", line 122, in new
    return Pafy(url, basic, gdata, size, callback, ydl_opts)
  File "/usr/local/lib/python3.6/site-packages/pafy/backend_internal.py", line 42, in __init__
    super(InternPafy, self).__init__(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pafy/backend_shared.py", line 96, in __init__
    self._fetch_basic()
  File "/usr/local/lib/python3.6/site-packages/pafy/backend_internal.py", line 75, in _fetch_basic
    sm_ciphertag = "s" in self.sm[0]
IndexError: list index out of range
gornostal commented 6 years ago

Looks like it works with youtube-dl installed

raju249 commented 6 years ago

No it doesn't. I get an error saying IOError: ERROR: requested format not available

kraetzin commented 6 years ago

@raju249 is your youtube-dl up to date?

$ youtube-dl --version
2018.02.04

I just tested this and here is what I get:

In [1]: import pafy

In [2]: pafy.backend
Out[2]: 'youtube-dl'

In [3]: pafy.new("https://www.youtube.com/watch?v=461zegf_Gv4")
Out[3]: 
Title: Summer Chill & Lounge Radio • 24/7 Chillout Music Live Stream | Deep & Lounge House Music Mix
Author: Chillout Lounge Music
ID: 461zegf_Gv4
Duration: 00:00:00
Rating: 4.76928853989
Views: 189761
Thumbnail: http://i.ytimg.com/vi/461zegf_Gv4/default.jpg

This seems to be working as intended.

raju249 commented 6 years ago

Let me check, will get back here by EOD (Indian standard time) 😊

raju249 commented 6 years ago

I wanted the audio stream url. It returns None and then my call fails on null pointer exception.