Beispiel #1
0
 def restore_json(self):
     original_json = util.get_path("docs") / ".catalog_names.json"
     user = messagebox.askyesno(
         message="new audio folder will be deleted. are you sure?")
     if user:
         new_json = util.catalog_file()
         shutil.copy(original_json, new_json)
         new_audio_dir = util.get_path("include/audio/new_audio")
         [os.remove(audio) for audio in new_audio_dir.iterdir()]
         messagebox.showinfo(message="done!")
Beispiel #2
0
def images_path() -> tuple():
    """Get images path from image directory.

    Returns:
        [tuple] - tuple list of images absolute path

    """
    img_directory = util.get_path("include/img")
    img_list = pathlib.Path(os.path.join(img_directory)).glob('*png')
    return [i for i in sorted(img_list)]
Beispiel #3
0
 def _update_audio_library(self):
     """Update audio library with deleting or adding the modifications."""
     for _, new_names in self._updated_names.items():
         for index, new_name in enumerate(new_names, 20):
             name, lang = new_name
             msg = f"Generating audio for: \n[{name}]"
             ttk.Label(self._options_frame, text=msg).grid(
                 column=3, row=index)
             path = util.get_path("include/audio/new_audio")
             util.generate_audio(text=name, path=path, lang=lang)
Beispiel #4
0
 def generate_archive(text):
     """Create a html file archive for later use."""
     today = datetime.today().strftime('%m.%d.%Y_%H:%M_')
     podcast_name = html_data['archive_name']
     file_path = os.path.join(util.get_path('archive'),
                              today + podcast_name + '.html')
     LOGGER.debug('creating html archive: %s', file_path)
     with open(file_path, 'w') as file:
         if test_env:
             text = test_path(text)
         file.write(text)
Beispiel #5
0
    def generate_new_audio(self, audio_list):
        """Gnerate new audio files for the intro.

        Arguments:
            audio_list {list/tuple} - iterable variable to generate new audio
        """
        path = util.get_path("include/audio/new_audio")

        for index, name in enumerate(audio_list, 10):

            msg = f"Generating audio for: {name}"
            ttk.Label(self._audio_frame, text=msg).grid(column=0, row=index)
            self.update()
            util.generate_audio(text=name, path=path)
Beispiel #6
0
 def debug_status(self):
     open_link(util.get_path("log") / "debug.log")
Beispiel #7
0
 def clean_log(self):
     log_path = util.get_path("log")
     for file in os.listdir(log_path):
         file_path = os.path.join(log_path, file)
         with open(file_path, "w") as f:
             pass
Beispiel #8
0
def archive_files():
    """Get all the html archives files."""
    path = pathlib.Path(util.get_path('archive')).glob('*html')
    for file in sorted(path):
        yield file