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