video upload on tweepy - python

I was trying to update my own status with only a video, but for some reason, it doesn't work. All of them are .mp4 with less than 1MB.
When I try upload_result = api.media_upload('file.mp4') it raises a TweepError saying that the file type could not be determined.
When I try upload_result = api.media_upload(filename = "path of the file", file = "file.mp4") it triggers [Errno13], saying "Permission Denied"
My IDE is Pycharm Community Edition and I am using python 3.9
If you want the full code, just ask for it in the comments

According to the Tweepy documentation you can only upload images
Use this endpoint to upload images to Twitter.
The upload of video is not currently supported, there is an issue open so it will probably come at some point.

Related

How to upload large files on Streamlit using st.file_uploader

I am trying to upload a binary file of size 10gb using st.file_uploader, however, I get the following error message. In fact, I get the same error message pretty much when I am trying to upload any file above 2gb, i.e I didn’t get this error message when I uploaded 1.2gb file.
I have set my file capacity to 10gb in config file.
As a matter of fact, the file loading shows as it should, then the file appears to be uploaded for a very short time (maybe a second), however, then the attachment disappears along with file_uploader widget itself, and the following message pops up.
By default, upload files are limited to 200MB. You can configure the server.maxUploadSize config option as such;
Set the config option in .streamlit/config.toml:
[server]
maxUploadSize=10000
https://github.com/streamlit/streamlit/issues/5938
The bug is raised in Streamlit repo. To be fixed.

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>

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

Pyrebase uploaded image not loading firebase storage

I'm not able to make this work, I want to upload a picture to firebase with pyrebase and the file(picture) goes through but it never loads on firebase/storage (see picture attached)
This is the code:
if request.method == 'POST':
upload = request.files['upload']
upload.save(os.path.join(UPLOAD_FOLDER, filename))
storage.child("images/test.jpg").put(UPLOAD_FOLDER+filename)
Last I heard, there is a bug in the Firebase console where images don't load if they were uploaded using one of the backend SDKs (as opposed to one of the Firebase client SDKs, or the Firebase console). It uses the "access token" that you would see in the "File location" section for that file. If there is no access token, the console won't know how to load the file.
If this is indeed the case for you, please file a bug with Firebase support. It's a known issue, but the report will let them know how many people are affected.
Clicking Create new access token under File Location solves the issue.

Why I can't configure OAuth 2.0 using Python?

I was trying to get my uploading YouTube video software to work using this guide/code:
https://developers.google.com/youtube/v3/guides/uploading_a_video
I installed & setup everything that is requiered. Also, I made new project, changed YouTube Data API v3's state to ON, got my credentials, entered them to client_secrets.json (also tried downloading one via button that google provided, btw. I renamed downloaded one to client_secrets.json manually, so that's not problem) but when I try to upload something I get this error:
C:\Users\%USERNAME%>c:/Python27/python.exe C:\Users\%USERNAME%\Documents\youtube_uploader\up
load.py --file=C:\Users\%USERNAME%\Documents\youtube_uploader\test_klip\test.mp4 --tit
le=Test upload
WARNING: Please configure OAuth 2.0
To make this sample run you will need to populate the client_secrets.json file
found at:
C:\Users\%USERNAME%\Documents\youtube_uploader\clientinfo.json
with information from the APIs Console
https://code.google.com/apis/console#access
For more information about the client_secrets.json file format, please visit:
https://developers.google.com/api-client-library/python/guide/aaa_client_secrets
Is there anything I missed or done wrong? If so, please help me to get this to work.
Thanks in advance! :)
P.S. I tried making and using both web/installed type of credentials but none of them work.

Categories

Resources