shekharchander / tube_dl Goto Github PK
View Code? Open in Web Editor NEWYoutube video downloader and info extractor for python.
License: MIT License
Youtube video downloader and info extractor for python.
License: MIT License
Getting an Error when running the following:
File "[myPath]\env\lib\site-packages\tube_dl_main_.py", line 64, in init
self.subscribers=extraDetails[1]['videoSecondaryInfoRenderer']["owner"]["videoOwnerRenderer"]["subscriberCountText"]["runs"][0]
KeyError: 'runs'
Traceback (most recent call last):
File "C:\Users\fixin\PycharmProjects\TTS\main.py", line 58, in <module>
save_to_file()
File "C:\Users\fixin\PycharmProjects\TTS\main.py", line 52, in save_to_file
Youtube(keys[key]).formats.filter_by(only_audio=True).first().download(convert="mp3")
File "C:\Users\fixin\PycharmProjects\TTS\venv\lib\site-packages\tube_dl\__main__.py", line 73, in __init__
self.description = ''.join([i["text"] for i in extraDetails[1]['videoSecondaryInfoRenderer']['description']["runs"]])
KeyError: 'description'
Nice package! Tried under linux and I had to modify formats.py.
final_path = f'{path}\{file_name}.{extension}'
to:
final_path = f'{path}' + os.path.sep + f'{file_name}.{extension}'
I'm sure there are other places that the separator should be fixed.
Python version>> 3.10.5
Command used for installation: "pip install tube_dl".
The tube_dl library was installed, but at the time of import it is not recognized, I imported the same as the usage tutorial, but it is not found or recognized, the command: "from tube_dl import Youtube" I did a search for cmd with the command "pip3 list" and it really said that it was installed, but when looking for the folder in tube_dl on venv, it is not, please help me, I need this library a lot.
I tried the following command:
print(Youtube('link here'))
and it returned back with the following error:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.8/site-packages/tube_dl/main.py", line 64, in init
self.subscribers=extraDetails[1]['videoSecondaryInfoRenderer']["owner"]["videoOwnerRenderer"]["subscriberCountText"]["runs"][0]
KeyError: 'runs'
It seems that after the first time using Token extracted from HTML, the author continues to use that token while the token already changed. To fix this problem, update to use new token to get full of playlist.
In python file containing class Playlist
In function:
def fetch_continuation(self, html):
#same code
return data
In function:
def __init__(self, url: str, start: int = None, end: int = None):
# same code
if total_count > 100:
start_html = html
for i in range(0, total_count//100):
start_html = self.fetch_continuation(start_html)
# same code
Hope this help.
import tube_dl
yt = tube_dl.Youtube("https://www.youtube.com/watch?v=eZYtnzODpW4")
print(yt.likes)
File "/home/matteo/.local/lib/python3.8/site-packages/tube_dl/__main__.py", line 75, in __init__
self.likes, self.dislikes = [i.strip() for i in extraDetails["sentimentBar"]["sentimentBarRenderer"]["tooltip"].split('/')]
KeyError: 'sentimentBar'
I'm downloading a video, https://m.youtube.com/watch?v=HhV_Y8C5YKo, and get the following error:
Traceback (most recent call last):
File "main.py", line 52, in <module>
download_audio(lin)
File "main.py", line 27, in download_audio
yt = Youtube(url).formats.filter_by(only_audio=True)[0]
File "/Users/jeff/Documents/Projects/pytubedl/venv/lib/python3.8/site-packages/tube_dl/__main__.py", line 75, in __init__
self.likes, self.dislikes = [i.strip() for i in extraDetails["sentimentBar"]["sentimentBarRenderer"]["tooltip"].split('/')]
according to your usage
from tube_dl import Youtube
yt = Youtube("https://youtube.com/watch?v=R2j46bHm6zw&list=RDAMVMd4HYhxlsj5k")
yt.formats.first().download()
Error:
yt = Youtube("https://youtube.com/watch?v=R2j46bHm6zw&list=RDAMVMd4HYhxlsj5k")
File "/usr/local/lib/python3.9/dist-packages/tube_dl/main.py", line 75, in init
self.likes=re.findall(r"'label': '(.*?) likes'",str(i))[0].replace(',','')
IndexError: list index out of range
code
from tube_dl import Youtube
Youtube("https://youtube.com/watch?v=R2j46bHm6zw&list=RDAMVMd4HYhxlsj5k").Formats()
result
FileNotFoundError Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/tube_dl/__main__.py](https://localhost:8080/#) in __init__(self, vid)
31 try:
---> 32 self.json_file = load(open(cwd+"/tube_dl_config.json", "rb"))
33 except FileNotFoundError:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.10/dist-packages/tube_dl/tube_dl_config.json'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
2 frames
[/usr/local/lib/python3.10/dist-packages/tube_dl/__main__.py](https://localhost:8080/#) in get_js(self)
107 js_file = get(js_url).text
108 data = Decipher(js_file, process=True).get_full_function()
--> 109 self.json_file['js'] = data
110 open(cwd+'/tube_dl_config.json', 'w').write(dumps(self.json_file))
111 return data
AttributeError: 'Youtube' object has no attribute 'json_file'
best regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.