glubsy / livestream_saver

Monitor a Youtube channel and download live-streams from the first segment
GNU General Public License v3.0
326 stars 39 forks source link

Exception while accessing title of video (possibly a pytube issue) #61

Open rrgodhorus opened 1 year ago

rrgodhorus commented 1 year ago

Downloads have started failing with this error recently. It is non-recoverable even when I try running the program again.

2023-03-17 07:10:29,798 - DEBUG - livestream_saver.monitor - Parsing json of selected tab: "Live"...
2023-03-17 07:10:29,798 - DEBUG - livestream_saver - Live videos found for channel "pirateaba": [{'videoId': 'OZk0x_ifOHg', 'thumbnail': {'thumbnails': [{'url': 'https://i.ytimg.com/vi/OZk0x_ifOHg/hqdefault_live.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBeMWCNasP14wOx-16yEtnZZYALcw', 'width': 168, 'height': 94}, {'url': 'https://i.ytimg.com/vi/OZk0x_ifOHg/hqdefault_live.jpg?sqp=-oaymwEbCMQBEG5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLAQ5OwusXr1Nz7Hvj3jG8PetEq_rA', 'width': 196, 'height': 110}, {'url': 'https://i.ytimg.com/vi/OZk0x_ifOHg/hqdefault_live.jpg?sqp=-oaymwEcCPYBEIoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBoOHzG0XFB8lq0Zd1srD5baZaIWw', 'width': 246, 'height': 138}, {'url': 'https://i.ytimg.com/vi/OZk0x_ifOHg/hqdefault_live.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBOHg9wJYTzaobPqcYpqNzrpvKdfQ', 'width': 336, 'height': 188}]}, 'isLiveNow': True, 'isLive': True, 'title': 'Interlude - I Have No Idea, Stream 1. Short chapter, interruptions, tired author.', 'url': '/watch?v=OZk0x_ifOHg'}, {'videoId': 'OZk0x_ifOHg', 'thumbnail': {'thumbnails': [{'url': 'https://i.ytimg.com/vi/OZk0x_ifOHg/hqdefault_live.jpg?sqp=-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBeMWCNasP14wOx-16yEtnZZYALcw', 'width': 168, 'height': 94}, {'url': 'https://i.ytimg.com/vi/OZk0x_ifOHg/hqdefault_live.jpg?sqp=-oaymwEbCMQBEG5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLAQ5OwusXr1Nz7Hvj3jG8PetEq_rA', 'width': 196, 'height': 110}, {'url': 'https://i.ytimg.com/vi/OZk0x_ifOHg/hqdefault_live.jpg?sqp=-oaymwEcCPYBEIoBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBoOHzG0XFB8lq0Zd1srD5baZaIWw', 'width': 246, 'height': 138}, {'url': 'https://i.ytimg.com/vi/OZk0x_ifOHg/hqdefault_live.jpg?sqp=-oaymwEcCNACELwBSFXyq4qpAw4IARUAAIhCGAFwAcABBg==&rs=AOn4CLBOHg9wJYTzaobPqcYpqNzrpvKdfQ', 'width': 336, 'height': 188}]}, 'isLiveNow': True, 'isLive': True, 'title': 'Interlude - I Have No Idea, Stream 1. Short chapter, interruptions, tired author.', 'url': '/watch?v=OZk0x_ifOHg'}]
2023-03-17 07:10:29,798 - DEBUG - livestream_saver.util - Creating output_dir: /Users/rajathreghunath/livestream_saver/UCGpHzPfE3vUwNIZDSSt4Uaw/stream_capture_OZk0x_ifOHg...
2023-03-17 07:10:29,798 - INFO - livestream_saver - Found live: OZk0x_ifOHg title: Interlude - I Have No Idea, Stream 1. Short chapter, interruptions, tired author.. Downloading...
2023-03-17 07:10:29,798 - DEBUG - livestream_saver.request - Making API request... endpoint='https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w&prettyPrint=false'
data={'context': {'client': {'clientName': 'ANDROID', 'clientVersion': '17.31.35', 'androidSdkVersion': 30, 'userAgent': 'com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip', 'hl': 'en'}}, 'videoId': 'OZk0x_ifOHg'}
headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0', 'Accept-Language': 'en-US,en', 'Content-Type': 'application/json', 'Origin': 'https://www.youtube.com', 'X-YouTube-Client-Name': '3', 'X-YouTube-Client-Version': '17.31.35'}
2023-03-17 07:10:30,034 - DEBUG - livestream_saver.request - Making API request... endpoint='https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w&prettyPrint=false'
data={'context': {'client': {'clientName': 'ANDROID', 'clientVersion': '17.31.35', 'androidSdkVersion': 30, 'userAgent': 'com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip', 'hl': 'en'}}, 'videoId': 'OZk0x_ifOHg'}
headers={'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:89.0) Gecko/20100101 Firefox/89.0', 'Accept-Language': 'en-US,en', 'Content-Type': 'application/json', 'Origin': 'https://www.youtube.com', 'X-YouTube-Client-Name': '3', 'X-YouTube-Client-Version': '17.31.35'}
2023-03-17 07:10:30,335 - ERROR - livestream_saver - Got error in stream download but continuing...
 Exception while accessing title of https://www.youtube.com/watch?v=OZk0x_ifOHg. Please file a bug report at https://github.com/pytube/pytube
Traceback (most recent call last):
  File "/Users/rajathreghunath/livestream_saver/livestream_saver/download.py", line 584, in title
    self._title = self.player_response['videoDetails']['title']
KeyError: 'videoDetails'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rajathreghunath/livestream_saver/livestream_saver.py", line 552, in monitor_mode
    livestream.download()
  File "/Users/rajathreghunath/livestream_saver/livestream_saver/download.py", line 923, in download
    f"Checking metadata items {(self.title, self.description)} against"
  File "/Users/rajathreghunath/livestream_saver/livestream_saver/download.py", line 591, in title
    raise pytube.exceptions.PytubeError(
pytube.exceptions.PytubeError: Exception while accessing title of https://www.youtube.com/watch?v=OZk0x_ifOHg. Please file a bug report at https://github.com/pytube/pytube
2023-03-17 07:10:30,336 - INFO - livestream_saver.monitor - Sleeping for 17.53 minutes (1051.70 seconds)...
glubsy commented 1 year ago

I believe this should be fixed by 8c3e166446bc5ec724319c5d9bc85c104dd39948 in the testing branch fix/regex_filters. It still needs some testing but if you're in a hurry you can try that branch.