I'm trying to write a python script that will download a youtube video, using this line of code for getting the download url:
download_url = "http://www.youtube.com/get_video?video_id={0}&t={1}&fmt=22&asv=2".format(video_id, token_value)
(video_id and token_values being info I've got from parsing youtube video url)
but this keeps downloading empty file.
Since this method is old, is there now some other form of getting download url for youtube videos?
I solved my problem (to some extent) in the meantime. I just had to access youtube video stream map and grab one of the URLs stored there and download the file. However, this works only on videos that don't have their signature encrypted. I'm still working on a solution for videos with encrypted signatures.
Related
Im trying to figure out how to search for and return a URL for a search term, I'm confused on how to request using python as my program is using discord.py.
What it does so far is that it can only play videos from a direct youtube link by downloading the video with youtube-dl and then converting it to audio with FFmpeg and playing it.
What I am trying to do is support the above mentioned (links) and detect whether the command is run with a link or not, if it's not a link, I would like it to search the term in Youtube using an HTTP request or similar and then return a URL to then be able to download and play it.
Any support on how I would get this to work? So far I have only found solutions in Javascript and I have absolutely no experience with java so I cant implement it.
I was watching a movie on hotstar and decided to download that movie. I will use Python to do that. But for that I need the video URL. I inspected the page and came to know that it has segmented streaming file.
The requested URL that I have highlighted in the picture is:
https://hses1.hotstar.com/videos/movies/bengali/sweater/1260011260/1569583501995/ad1f5bdbac36f489da1adb7f077be226/video/avc1/3/seg-1306.m4s
It has a .m4s extension. How to read that file? Or how to work with it using Python?
USE IDM to download movie, or you can scrape bit there must be m3u8 link as well which might be not in use as of now
So I am writing a simple script to extract links from a Youtube video, and then download the audio from each of the links. Extracting the links I got down using urllib, however, youtube_dl is being more problematic.
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download(["https://www.youtube.com/watch?v=YQHsXMglC9A"])
I have the correct "ydl_opts" and everything, but it keeps rasing:
DownloadError: ERROR: ffprobe or avprobe not found. Please install one.
Even after Googling this, and installing ffprobe, I keep getting this error... and the weird thing is I can import ffprobe at the beginning of the program but youtube_dl doesn't detect it(?).
So I am trying another idea:
Use a third party website like "youtube-mp3.org", get a template link like:
"""http://www.youtube-mp3.org/get?video_id={1}&ts_create=1451072960&r=MjQuMjEuMTc5LjU2&h2=12c386ccffa12ee7b16dd25078df2558&s=156489""".format(video_link_id)
... then formatting it with Youtubes unique video ID, and download it with urllib.urlopen(), but that download link generates unique arguments that can't be used with other videos. So is there a way to download from a website like that, and/or supply argument like changing the download URL algorithm? Or something to that effect?
Overall objective:
Get Youtube video ID
Download and convert to mp3 or similar format
Play audio within Python
Bonus:
Do it as efficiently and quickly as possible (i.e Not downloading entire video, or extra conversion steps)
I can recommend you a package called pytube.
I have used it and am very pleased with the results. It downloads the video, and after that you can use a library to extract only the audio.
Hope it helps.
I am trying to download a video from Youtube, and have tried the following:
url = "http://www.youtube.com/watch?v=f4l3pBovB_c"
urllib.urlretrieve(url,"test.mp4")
It creates the file test.mp4, but got the following error:
Windows media player cannot play the file. The Player might not
support the file type or might not support the codec that was used to
compress the file.
I would like to try to understand how to accomplish this myself, I have seen modules like youtube-dl.py, but again would like to get the code working in it's simplest form so I can understand the script as I build it.
Youtube videos are not stored on youtube.com domain, so the video which you are trying to download does not exist that URL. Downloading a youtube video is a complicated process but you can use youtube-dl for it.
I am uploading video to youtube by using their API. After the successful upload, i want to get the video id which i am unable to find. I have found this in the video_entry object as id.
<ns0:id xmlns:ns0="http://www.w3.org/2005/Atom">http://gdata.youtube.com/feeds/api/videos/nK1Ax6320T8</ns0:id>
Here, nK1Ax6320T8 is the video id. How can i parse it in python. Kindly help.
You'll need to parse that url parameters, Python provides a good library to do that.
There's good sample code from the YouTube data API docs that does exactly what you're asking about. Checkout line 76.