fix vk audio #2
This commit is contained in:
parent
fc08abd83e
commit
f64e76daa0
@ -1,22 +1,14 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import re
|
||||||
import tempfile
|
import tempfile
|
||||||
from io import BytesIO
|
|
||||||
from uuid import uuid4
|
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
def get_vk_audio(m3u8):
|
def get_vk_audio(url):
|
||||||
with tempfile.TemporaryDirectory() as d:
|
if 'm3u8' in url:
|
||||||
fname = '{}.mp3'.format(uuid4())
|
url = re.sub(r'/[0-9a-f]+/([0-9a-f]+)/index.m3u8', r'/\1.mp3', s)
|
||||||
path = os.path.join(d, fname)
|
return get_file(url)
|
||||||
subprocess.check_output(['ffmpeg', '-i', m3u8, path])
|
|
||||||
with open(path, 'rb') as f:
|
|
||||||
tf = BytesIO(f.read())
|
|
||||||
tf.name = fname
|
|
||||||
tf.seek(0)
|
|
||||||
return tf
|
|
||||||
|
|
||||||
|
|
||||||
def get_vk_photo(attachment):
|
def get_vk_photo(attachment):
|
||||||
|
Loading…
Reference in New Issue
Block a user