How to stream video in python from youtube - python

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/

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>

Is there a way to call download() in Pytube to download a video into a variable?

I see that Pytube provides a download() method to download a video to a file. However, in the event that I don't want to download it to disk and want to store it in a variable to store in a list of videos, how can this be done?

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)

ERROR: unable to download video data: HTTP Error 403: Forbidden while using youtube_dl

I am trying to download songs from youtube using python 3.8 and youtube_dl 2020.3.24.
But the weird thing is that most songs I try to download don't get downloaded. I'm talking 99% of them.
The ones that do get downloaded get the following Error from youtube_dl:
ERROR: unable to download video data: HTTP Error 403: Forbidden
It is worth saying that this happened overnight and I did not change any code.
before this everything worked fine.
I have friends who ran the same code and they did not get this Error
Same problem many times ..
solution: youtube-dl --rm-cache-dir
Cause of the problem: Sometimes I download playlists of large videos and I force it to stop downloading, the next time I run the command to resume the download, the 403 problem arises
At the moment, the cache directory is used only to store youtube players for obfuscated signatures. Since all videos in playlist use simple signatures
Playlist caching is an obvious way to detect changed titles or changed playlists in general
It seems like i have figured it out on my own.
The Error went away after i cleared the cache.
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
try:
ydl.cache.remove()
ydl.download([youtube_link])
except youtube_dl.DownloadError as error:
pass
Any info on why this works is welcome

How to use the PivotalTracker API with Python 2.7

I am trying to use the PivotalTracker API to get all the stories from an epic. I am very lost on where to begin. I looked at the samples, but they are using cURL, not python. I also stumbled upon the pytracker module but it is 4 years old and is obsolete as PivotalTracker has switched over from XML to JSON during that time. Again I'm very lost on where to start, but appreciate any guidance you have to offer, thanks!
So I ended up installing the Requests module for Python and managed to make the cURL requests through that. Here is how to do it: https://stackoverflow.com/a/25797678/1536101
You can use the pytracker wrapper library: https://code.google.com/p/pytracker/
Or, you would directly use urllib to call Pivotal Tracker's restful APIs: https://docs.python.org/2/library/urllib.html

Categories

Resources