Skip to content

Commit

Permalink
Add logic for filling gap in the main module
Browse files Browse the repository at this point in the history
  • Loading branch information
dplocki committed Feb 16, 2024
1 parent 97ed388 commit 86d2eda
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
29 changes: 19 additions & 10 deletions podcast_downloader/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
parse_day_label,
)
from .utils import ConsoleOutputFormatter, compose
from .downloaded import get_downloaded_files, get_extensions_checker
from .downloaded import (
get_downloaded_files,
get_extensions_checker,
get_last_downloaded_file_before_gap,
)
from .parameters import merge_parameters_collection, load_configuration_file, parse_argv
from .rss import (
RSSEntity,
Expand Down Expand Up @@ -237,17 +241,22 @@ def configuration_to_function_rss_to_name(
)

all_feed_files = list(map(to_real_podcast_file_name, all_feed_entries))

downloaded_files = [feed for feed in all_feed_files if feed in downloaded_files]

last_downloaded_file = downloaded_files[0] if downloaded_files else None


download_limiter_function = (
partial(build_only_new_entities(to_name_function), last_downloaded_file)
if last_downloaded_file
else on_directory_empty
)
last_downloaded_file = None
if downloaded_files:
if rss_fill_up_gaps:
last_downloaded_file = get_last_downloaded_file_before_gap(
all_feed_files, downloaded_files
)
download_limiter_function = None
else:
last_downloaded_file = downloaded_files[0]
download_limiter_function = partial(
build_only_new_entities(to_name_function), last_downloaded_file
)
else:
download_limiter_function = on_directory_empty

missing_files_links = compose(list, download_limiter_function)(all_feed_entries)

Expand Down
4 changes: 4 additions & 0 deletions podcast_downloader/downloaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ def get_downloaded_files(
for file in get_files_from(podcast_directory)
if podcast_files_filter(file) and is_directory_file(file)
)


def get_last_downloaded_file_before_gap():
pass

0 comments on commit 86d2eda

Please sign in to comment.