Ejemplo n.º 1
0
 def download_assets(self, assets, filepath):
     """This function will simply download the asstes.."""
     if assets:
         for asset in assets:
             title = asset.filename
             logger.info(msg="Downloading asset(s)",
                         new_line=True,
                         before=True)
             logger.info(msg=f"Downloading ({title})", new_line=True)
             try:
                 retval = asset.download(
                     filepath=filepath,
                     quiet=True,
                     callback=self.show_progress,
                 )
                 msg = retval.get("msg")
                 if msg == "already downloaded":
                     logger.already_downloaded(msg=f"Asset : '{title}'")
                 elif msg == "download":
                     logger.info(msg=f"Downloaded  ({title})",
                                 new_line=True)
                 else:
                     logger.download_skipped(msg=f"Asset : '{title}' ",
                                             reason=msg)
             except KeyboardInterrupt:
                 logger.error(msg="User Interrupted..", new_line=True)
                 sys.exit(0)
Ejemplo n.º 2
0
 def download_lecture(self, lecture, filepath, current, total, quality):
     """This function will simply download the lectures.."""
     if quality and lecture:
         lecture = lecture.get_quality(quality)
     if lecture:
         title = lecture.title
         logger.info(msg=f"Lecture(s) : ({current} of {total})",
                     new_line=True,
                     before=True)
         logger.info(msg=f"Downloading ({title})", new_line=True)
         try:
             retval = lecture.download(
                 filepath=filepath,
                 quiet=True,
                 callback=self.show_progress,
             )
             msg = retval.get("msg")
             if msg == "already downloaded":
                 logger.already_downloaded(msg=f"Lecture : '{title}'")
             elif msg == "download":
                 logger.info(msg=f"Downloaded  ({title})", new_line=True)
             else:
                 logger.download_skipped(msg=f"Lecture : '{title}' ",
                                         reason=msg)
         except KeyboardInterrupt:
             logger.error(msg="User Interrupted..", new_line=True)
             sys.exit(0)
Ejemplo n.º 3
0
 def download_subtitles(self, subtitles, filepath, language="en", keep_vtt=False):
     """This function will simply download the subtitles.."""
     if language and subtitles:
         subtitle = subtitles[0]
         subtitles = subtitle.get_subtitle(language)
     if subtitles:
         for sub in subtitles:
             title = f"{sub.title}.{sub.language}"
             filename = os.path.join(filepath, sub.filename)
             logger.info(msg="Downloading subtitle(s)", new_line=True, before=True)
             logger.info(msg=f"Downloading ({title})", new_line=True)
             try:
                 retval = sub.download(
                     filepath=filepath, quiet=True, callback=self.show_progress,
                 )
                 msg = retval.get("msg")
                 if msg == "already downloaded":
                     logger.already_downloaded(msg=f"Subtitle : '{title}'")
                 elif msg == "download":
                     logger.info(msg=f"Downloaded  ({title})", new_line=True)
                     self.convert(filename=filename, keep_vtt=keep_vtt)
                 else:
                     logger.download_skipped(
                         msg=f"Subtitle : '{title}' ", reason=msg
                     )
             except KeyboardInterrupt:
                 logger.error(msg="User Interrupted..", new_line=True)
                 sys.exit(0)