pytube, How to download private YouTube video? - python

I have code to download YouTube video, but it can not download private video link.Can someone help me how to modify code?
from pytube import YouTube
yt = YouTube('https://www.youtube.com/watch?v=p8nlTw-SOMETHING')
yt.streams \
.filter(progressive=True, file_extension='mp4') \
.order_by('resolution') \
.desc() \
.first() \
.download()')

Hey i used Pytube to create a Youtube MP3/MP4 downloader and had this problem, you can not download private videos if they are your videos change them to public or at least unlisted.
If you would like i can comment my github repository for my youtube downloader for you to see what i did or gain inspiration from it aswell

Related

how to download a video from a twitch clip in python [duplicate]

I have been trying to download past broadcasts for a streamer on twitch using python. I found this python code online:
https://gist.github.com/baderj/8340312
However, when I try to call the functions I am getting errors giving me a status 400 message.
Unsure if this is the code I want to download the video (as an mp4) or how to use it properly.
And by video I mean something like this as an example: www(dot)twitch.tv/imaqtpie/v/108909385 //note cant put more than 3 links since I don't have 10 reputation
Any tips on how i should go about doing this?
Here's an example of running it in cmd:
python twitch_past_broadcast_downloader.py 108909385
After running it, it gave me this:
Exception API returned 400
This is where i got the information on running it:
https://www.johannesbader.ch/2014/01/find-video-url-of-twitch-tv-live-streams-or-past-broadcasts/
Huh it's not as easy at it seems ... The code you found on this gist is quite old and Twitch has completely changed its API. Now you will need a Client ID to download videos, in order to limit the amount of video you're downloading.
If you want to correct this gist, here are simple steps you can do :
Register an application : Everything is explained here ! Register you app and keep closely your client id.
Change API route : It is no longer '{base}/api/videos/a{id_}' but {base}/kraken/videos/{id_} (not sure about the last one). You will need to change it inside the python code. The doc is here.
Add the client id to the url : As said in the doc, you need to give a header to the request you make, so add a Client-ID: <client_id> header in the request.
And now I think you will need to start debugging a bit, because it is old code :/
I will try myself to do it and I will edit this answer when I'm finished, but try yourself :)
See ya !
EDIT : Mhhh ... It doesn't seem to be possible anyway to download a video with the API :/ I was thinking only links to API changed, but the chunks section of the response from the video url disappeared and Twitch is no longer giving access to raw videos :/
Really sorry I told you to do that, even with the API I think is no longer possible :/
You can download past broadcasts of Twitch videos with Python library streamlink.
You will need OAuth token which you can generate with the command
streamlink --twitch-oauth-authenticate
Download VODs with:
streamlink --twitch-oauth-token <your-oauth-token> https://www.twitch.tv/videos/<VideoID> best -o <your-output-folder>

How to stream video in python from youtube

i used to solve this problem pafy. But now this library not working, because youtube change something and pafy haven't any udate. So i need to new way.
I found new library.The library is called Pytube https://pypi.org/project/pytube/

Download Youtube subtitles without timer using pytube

I am using pytube to download subtitles of youtube video. I want to download them without time information. I have checked their API documentation but I am unable to find option to get subtitle without timer. Following is my code.
from pytube import YouTube
source = YouTube('https://www.youtube.com/watch?v=6Af6b_wyiwI')
en_caption = source.captions.get_by_language_code('en')
en_caption_convert_to_srt =(en_caption.generate_srt_captions())
print(en_caption_convert_to_srt)

How to integrate Vimeo API to Search Public Videos by keywords in python

i am creatin a project which includes integrating some major Video Network in Python.. My Main Objective is to make people search public videos by input keywords. I have done foe Youtube and now i want something similar with Vimeo but i don't get any idea on how there URI Request works.. As for Youtube i used the below codes to make a video search through the API..
import requests
def browse_video_by_keyword(search , pageToken):
_KEY = 'AIzaSyAlpM2iiTfLFUvEs3dR5IsHKX-wOJzh_uo'
url = 'https://www.googleapis.com/youtube/v3/search?key={api_key}&part=snippet,id&pageToken={page}&maxResults=24&q={keyword}'
request = requests.get(url.format(api_key=_KEY , keyword=search , page=pageToken))
res = request.json()
return res["items"];
I Need someone to give me idea on how i can do something similar to this for Vimeo API.. I have search through very where i can but no get any idea.. Any Help would be appreciated. Thanks In advance..
Looking at Vimeo API documentation, I think you need to hit their "Search for videos" end point. You can read more on it here

Retrieve feed from a specific category with appengine python youtube api

http://code.google.com/apis/youtube/articles/youtube_api_appengine.html Following this tutorial I am able to retrive the most recent video feeds for my service.
feed = client.GetRecentlyFeaturedVideoFeed()
with the above command, I would like to retrieve videos for the four standar youtube categories news, comedy, sports, music so I guess I should query it somehow like:
feed = client.Query('http://gdata.youtube.com/feeds/api/videos/-/Comedy?v=2')
I am not able to figure out the syntax or even if I going the right direction.
It was quite simple in a similar post
feed = client.GetYouTubeVideoFeed('http://gdata.youtube.com/feeds/api/videos/-/Comedy?v=2')
and the relevant post: How to get the public channel URL from YouTubeVideoFeed object using the YouTube API?

Categories

Resources