From f64e76daa090f0b01a49e8e0b66212da8011cfe8 Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Sun, 27 Oct 2019 02:18:55 +0300 Subject: [PATCH] fix vk audio #2 --- feeds/modules/utils.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/feeds/modules/utils.py b/feeds/modules/utils.py index 0fb23b9..f402add 100644 --- a/feeds/modules/utils.py +++ b/feeds/modules/utils.py @@ -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):