From 48cce30f03d234e62b837f95413a1d8c9b9cd6a4 Mon Sep 17 00:00:00 2001
From: Eliot Berriot <contact@eliotberriot.com>
Date: Sun, 18 Jun 2017 18:33:09 +0200
Subject: [PATCH] FIxed broken import

---
 funkwhale_api/downloader/downloader.py            | 5 ++---
 funkwhale_api/downloader/tests/test_downloader.py | 7 ++++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/funkwhale_api/downloader/downloader.py b/funkwhale_api/downloader/downloader.py
index 854d0d0..b35ed6f 100644
--- a/funkwhale_api/downloader/downloader.py
+++ b/funkwhale_api/downloader/downloader.py
@@ -11,7 +11,6 @@ def download(
         url,
         target_directory=settings.MEDIA_ROOT,
         name="%(id)s.%(ext)s",
-        extension='vorbis',
         bitrate=192):
     target_path = os.path.join(target_directory, name)
     ydl_opts = {
@@ -19,10 +18,10 @@ def download(
         'outtmpl': target_path,
         'postprocessors': [{
             'key': 'FFmpegExtractAudio',
-            'preferredcodec': extension,
+            'preferredcodec': 'vorbis',
         }],
     }
     _downloader = youtube_dl.YoutubeDL(ydl_opts)
     info = _downloader.extract_info(url)
-    info['audio_file_path'] = target_path.format(**info)
+    info['audio_file_path'] = target_path % {'id': info['id'], 'ext': 'ogg'}
     return info
diff --git a/funkwhale_api/downloader/tests/test_downloader.py b/funkwhale_api/downloader/tests/test_downloader.py
index 77164d5..7cfaa63 100644
--- a/funkwhale_api/downloader/tests/test_downloader.py
+++ b/funkwhale_api/downloader/tests/test_downloader.py
@@ -8,6 +8,7 @@ class TestDownloader(TMPDirTestCaseMixin, TestCase):
 
     def test_can_download_audio_from_youtube_url_to_vorbis(self):
         data = downloader.download('https://www.youtube.com/watch?v=tPEE9ZwTmy0', target_directory=self.download_dir)
-        self.assertTrue(
-            os.path.exists(os.path.join(self.download_dir, 'tPEE9ZwTmy0.ogg'))
-        )
+        self.assertEqual(
+            data['audio_file_path'],
+            os.path.join(self.download_dir, 'tPEE9ZwTmy0.ogg'))
+        self.assertTrue(os.path.exists(data['audio_file_path']))
-- 
GitLab