pytube: [BUG] Exception while accessing title
PY Script:
> file1 = open('YTVlist.txt', 'r')
> Urls = file1.readlines()
> file2 = open('YTVTitles.txt', 'w', encoding='utf-8')
> for line in Urls:
> dummy = []
> try:
> yt = YouTube(line)
> except VideoUnavailable:
> print('Video {line} is unavaialable, skipping.')
> file2.write('Video {line} is unavaialable, skipping.')
> else:
> print(YouTube(line).title + ";" + line)
> dummy = YouTube(line).title
> #TL = dummy.encode('utf-8')
> file2.write(dummy + ";" + line)
OUTPUT:
Traceback (most recent call last): File “C:\Python\Python310\lib\site-packages\pytube_main_.py”, line 341, in title self._title = self.vid_info[‘videoDetails’][‘title’] KeyError: ‘videoDetails’
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File “C:\Users\ricca\Documents\PythonFiles\YouTube_Get_Title-Author.py”, line 35, in <module> print(YouTube(line).title + “;” + line) File “C:\Python\Python310\lib\site-packages\pytube_main_.py”, line 346, in title raise exceptions.PytubeError( pytube.exceptions.PytubeError: Exception while accessing title of https://youtube.com/watch?v=ZL44_lhJCPg. Please file a bug report at https://github.com/pytube/pytube
pytube updated via GitHub for Windows $ py -m pip install git+https://github.com/pytube/pytube
C:\Users\ricca\Documents\PythonFiles>py --version Python 3.10.8
C:\Users\ricca\Documents\PythonFiles>pip install pytube Requirement already satisfied: pytube in c:\python\python310\lib\site-packages (12.1.2)
C:\Users\ricca\Documents\PythonFiles>
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 24 (1 by maintainers)
Commits related to this issue
- fix bug with title in pytube see: https://github.com/pytube/pytube/issues/1473#issuecomment-1575336046 — committed to atilatech/atila-core-service by ademidun a year ago
As of now, this helps: https://github.com/pytube/pytube/commit/c0d1aca42c4106e77ab4f8a0600737ea2ad27a96#diff-34b7de4e054a59b9c9a386a81fac050960951773737b50b5c8b746db6a364d47
I am also getting that error a lot. I am able to get around this with this little hack:
pytube.innertube._default_clients['ANDROID']=pytube.innertube._default_clients['WEB']
Solution from @Shinku-Chen https://github.com/pytube/pytube/commit/c0d1aca42c4106e77ab4f8a0600737ea2ad27a96#commitcomment-111941588
I want to point out that this issue was probably one of the first, but also there is an ongoing explosion of new issues referring to this same problem - and many of them don’t even have an issue title…
The lack of the most basic etiquette is astounding. My sympathy to the maintainers first and foremost and to anyone earnestly attempting to help amidst the chaos.