social media video downloader

FREEMIUM
By ugoBoy | Updated 5 days ago | Social
Popularity

9.8 / 10

Latency

2,869ms

Service Level

100%

Health Check

100%

Back to All Discussions

Can't Download Youtube Audio.With Python code

Rapid account: Karshiboyevilyosbek

API Is good but i can’t download audio with python code.Who can help me download this

Rapid account: Ugo Boy
ugoBoy Commented 14 days ago

The url doesn’t return a json, so you shouldn’t be parsing it as json at json_data = json.loads(data)

Rapid account: Karshiboyevilyosbek
karshiboyevilyosbek Commented 14 days ago

Here is my code.This code can’t give me audio.But I can download videos with this code.

Do you have solution in Python ???

Rapid account: Karshiboyevilyosbek
karshiboyevilyosbek Commented 14 days ago

async def save_audio(url):
chunk_size = 20 * 2 ** 20 # 20 MB
file_name = f"media/{shortuuid.uuid()}.mp3" # Save as mp3
with open(file_name, ‘wb’) as f:
async with aiohttp.ClientSession() as session:
async with session.get(url) as response:
data = await response.read()
json_data = json.loads(data)
audio_url = json_data.get(‘url’)
if audio_url:
async with session.get(audio_url) as audio_response:
while True:
chunk = await audio_response.content.read(chunk_size)
if not chunk:
break
f.write(chunk)
return file_name

Rapid account: Ugo Boy
ugoBoy Commented 19 days ago

can you show you’re code?

Join in the discussion - add comment below:

Login / Signup to post new comments