From f1ddf104809017784aa136ebb8ff7e2cfb96d5f4 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Sun, 11 Oct 2015 00:15:23 +0200 Subject: Changed directory structure to use pyscaffold --- youtube/downloader.py | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100644 youtube/downloader.py (limited to 'youtube/downloader.py') diff --git a/youtube/downloader.py b/youtube/downloader.py deleted file mode 100644 index ca1327b..0000000 --- a/youtube/downloader.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 - -import youtube_dl -import os - - -class Downloader: - instance = None - - def get_instance(file_format, location, base_url): - if Downloader.instance: - return Downloader.instance - else: - Downloader.instance = Downloader(file_format, location, base_url) - return Downloader.instance - - def __init__(self, file_format, location, base_url): - self.file_format = file_format - self.location = location - self.base_url = base_url - - def download(self, video, video_id, feed_id): - output = "%s/%s/%s.ogg" % (self.location, feed_id, video_id) - options = {"format": "bestaudio/best", - "outtmpl": output, - "postprocessors": [{ - "key": "FFmpegExtractAudio", - "preferredcodec": self.file_format - }], - "nooverwrites": True - } - - video_url = "https://www.youtube.com/watch?v=%s" % (video["snippet"]["resourceId"]["videoId"]) - youtube_dl.YoutubeDL(options).download([video_url]) - - url = "%s/%s/%s.ogg" % (self.base_url, feed_id, video_id) - size = str(os.path.getsize(output)) - mime = "audio/ogg" - - return (url, size, mime) - -# vim: set ts=8 sw=4 tw=0 et : -- cgit v1.2.3