Issue
Hey guys I need some help, I am trying to download videos from this sitehttps://ttdownloader.com/dl.php?v=YTo0OntzOjk6IndhdGVybWFyayI7YjowO3M6NzoidmlkZW9JZCI7czoxOToiNjkxMjEwNzYyNzY1MjY5NzM1MCI7czozOiJ1aWQiO3M6MzI6Ijk0MTdiOWE3NWU2MmE3MDQ1NjZhYzk0MzJjMThlY2VlIjtzOjQ6InRpbWUiO2k6MTYxMTQ5NzE1ODt9 using python.
this is code I have tried.
import requests
url ='''https://ttdownloader.com/dl.php?v=YTo0OntzOjk6IndhdGVybWFyayI7YjowO3M6NzoidmlkZW9JZCI7czoxOToiNjkxMjEwNzYyNzY1MjY5NzM1MCI7czozOiJ1aWQiO3M6MzI6Ijk0MTdiOWE3NWU2MmE3MDQ1NjZhYzk0MzJjMThlY2VlIjtzOjQ6InRpbWUiO2k6MTYxMTQ5NzE1ODt9'''
page = requests.get(url)
with open('output.mp4', 'wb') as file:
file.write(page.content)
But it doesnt work as expected, when i check page.content all I see is b''
Solution
❌ The link that you are using is NOT a html page.
❌ Therefore it doesn't return anything as html.
✅ Your link is a media link.
✅ Therefore you must stream it and download it. Something like this:
import requests
url = '/your/valid/ttdownloader/url'
with requests.get(url, stream=True) as r:
with open('ouput.mp4', 'wb') as f:
for chunk in r.iter_content(chunk_size=8192):
f.write(chunk)
NOTE:
The link that you posted in the question is now invalid.
Please try the above code with a newly generated link.
Answered By - anjandash
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.