def test_format_note(self): pdl = PluraDL() self.assertEqual(pdl._format_note({}), '') assertRegexpMatches(self, pdl._format_note({ 'vbr': 10, }), r'^\s*10k$') assertRegexpMatches(self, pdl._format_note({ 'fps': 30, }), r'^30fps$')
def invoke_download(course_id, course_url, coursepath): """Using plura_dl API to invoke download requests with associated parameters. Arguments: course_id {str} -- Course identifier course_url {str} -- Playlist url coursepath {str} -- Local temporary course storage path Returns: Bool -- Validation of completion level """ with PluraDL(PDL_OPTS) as pdl: try: # Invoke download set_directory(coursepath) pdl.download([course_url]) # Moving content to _finished destination path if the download was sucessful pdl.to_stdout("The course '" + course_id + "' was downloaded successfully.") move_content(pdl, course_id, coursepath, FINISHPATH) return True except ExtractorError: # Handling the case of invalid download requests pdl.to_stdout("The course '" + course_id + "' may not be a part of your current licence.") pdl.to_stdout("Visit " + course_url + " for more information.\n") # Moving content to _failed destination move_content(pdl, course_id, coursepath, FAILPATH) return True except DownloadError: # Handling the the more general case of download error pdl.to_stdout("Something went wrong.") pdl.to_stdout("The download request for '" + course_id + "' was forced to terminate.") pdl.to_stdout("Double check that " + course_url) pdl.to_stdout( "exists or that your subscription is valid for accessing its content.\n" ) # Moving content to _failed destination path move_content(pdl, course_id, coursepath, FAILPATH) return True except KeyboardInterrupt: # Handling the case of user interruption pdl.to_stdout("\n\nThe download stream for '" + course_id + "' was canceled by user.") # Moving content to _canceled destination move_content(pdl, course_id, coursepath, INTERRUPTPATH) return False
def run_pp(params, PP): with open(filename, 'wt') as f: f.write('EXAMPLE') pdl = PluraDL(params) pdl.add_post_processor(PP()) pdl.post_process(filename, {'filepath': filename})
def fname(templ): pdl = PluraDL({'outtmpl': templ}) return pdl.prepare_filename(info)