def process(self, count=-1): failedTasks = []; c = 0; while (len(self)>0): if ((count>0 and c==count)): break; task = self.pop(); if (type(task) is PodcastSyncTaskEpisodePush): print "Performing push operation to " + task.syncDestination.serviceName + ": " + task.metaData.title; print "Downloading podcast file..." fileDownloader = FileDownloader(task.metaData.enclosureURL); #Download the podcast file (ie mp3) fn, file_extension = os.path.splitext(task.metaData.enclosureURL) filename = fileDownloader.downloadToTempFile(file_extension); task.localFilename = filename; print "File Downloaded. Applying tags to file..." audio = mutagen.File(filename, easy=True) audio['title'] = task.metaData.title; audio['artist'] = task.metaData.parentPodcast.author; audio['album'] = task.metaData.parentPodcast.title; audio.save(); print "Pushing to Destination..." songID = task.syncDestination.pushEpisode(task); task.owningPodFastPodcast.addPushedEpisode(songID, task.metaData.getHashedGUID(),task.syncDestination) if (type(task) is PodcastSyncTaskEpisodePull): task.syncDestination.pullEpisode(task); c += 1; return failedTasks;
def downloadArtworkImage(self): if (self.image is None or self.imageDataFile is not None): return; print "Downloading Artwork..."; fileDownloader = FileDownloader(self.image); filename, file_extension = os.path.splitext(self.image) filename = fileDownloader.downloadToTempFile(file_extension) self.imageDataFile = filename;
def downloadUrl(self, url, progress_hook): infos = self._ydl.extract_info(url, download=False) params = {} params["quiet"] = True downloader = FileDownloader(self, params) downloader.add_progress_hook(progress_hook) self.downloader = downloader target = os.path.join(os.getcwd(), "data", url.split("/")[-1]) real_url = self._get_url_from_infos(infos) print "real url is : ", real_url downloader._do_download(unicode(target), real_url)
def fetchMetaData(self): fileDownloader = FileDownloader(self.XMLURL); metaDataXML = fileDownloader.downloadToString(); self.metaData = PodcastMetaData(); self.metaData.XMLDecode(metaDataXML);
cookiefile = opts['cookiefile'] jar = cookielib.MozillaCookieJar(cookiefile) if os.path.isfile(cookiefile) and os.access(cookiefile, os.R_OK): jar.load() except (IOError, OSError), err: sys.exit(u'ERROR: unable to open cookie file') else: jar = cookielib.CookieJar() # General configuration cookie_processor = urllib2.HTTPCookieProcessor(jar) proxy_handler = urllib2.ProxyHandler() opener = urllib2.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler()) socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words) fd = FileDownloader(opener, opts) extractors = gen_extractors() for extractor in extractors: fd.add_info_extractor(extractor) # PostProcessors if 'extractaudio' in opts: fd.add_post_processor(FFmpegExtractAudioPP(preferredcodec=opts.audioformat, preferredquality=opts.audioquality, keepvideo=opts.keepvideo)) return fd def gen_extractors(): """ Return a list of an instance of every supported extractor.