Skip to content

Commit

Permalink
don't try to fetch tv episodes as frequently if it's been released fo…
Browse files Browse the repository at this point in the history
…r a while and has attempted recently
  • Loading branch information
lardbit committed Oct 13, 2024
1 parent 25ca2d5 commit 76f677a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/nefarious/parsers/movie.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class MovieParser(ParserBase):
regex.compile(r"^(?<title>(?![(\[]).+?)((\W|_))(?:(?<!(19|20)\d{2}.)(German|French|TrueFrench))(.+?)(?=((19|20)\d{2}|$))(?<year>(19|20)\d{2}(?!p|i|\d+|\]|\W\d+))?(\W+|_|$)(?!\\)", regex.I),
),
(
'Special, Despecialized, etc. Edition Movies, e.g: Mission.Impossible.3.Special.Edition.2011',
'Special, Despecialized, etc. Edition Movies, e.g.: Mission.Impossible.3.Special.Edition.2011',
regex.compile(r"^(?<title>(?![(\[]).+?)?(?:(?:[-_\W](?<![)\[!]))*\(?(?<edition>(((Extended.|Ultimate.)?(Director.?s|Collector.?s|Theatrical|Ultimate|Final(?=(.(Cut|Edition|Version)))|Extended|Rogue|Special|Despecialized|\d{2,3}(th)?.Anniversary)(.(Cut|Edition|Version))?(.(Extended|Uncensored|Remastered|Unrated|Uncut|IMAX|Fan.?Edit))?|((Uncensored|Remastered|Unrated|Uncut|IMAX|Fan.?Edit|Edition|Restored|((2|3|4)in1))))))\)?.{1,3}(?<year>(19|20)\d{2}(?!p|i|\d+|\]|\W\d+)))+(\W+|_|$)(?!\\)", regex.I),
),
(
'Normal movie format, e.g: Mission.Impossible.3.2011',
'Normal movie format, e.g.: Mission.Impossible.3.2011',
regex.compile(r"^(?<title>(?![(\[]).+?)?(?:(?:[-_\W](?<![)\[!]))*(?<year>(19|20)\d{2}(?!p|i|(19|20)\d{2}|\]|\W(19|20)\d{2})))+(\W+|_|$)(?!\\)", regex.I),
),
(
Expand Down
13 changes: 12 additions & 1 deletion src/nefarious/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,18 @@ def wanted_media_task():

for media_type, data in wanted_media_data.items():
for media in data['query']:
# media has been released (or it's missing it's release date so try anyway) so create a task to try and fetch it
# skip episodes attempts if last attempt was within x days, and we're past release date by x days
if media_type == 'episode':
days_since_last_attempt = (today - media.last_attempt_date).days if media.last_attempt_date else None
days_since_release = abs(today - media.release_date).days if media.release_date else None
is_too_recent_to_check_for_old_episodes = all([
days_since_last_attempt is not None and days_since_last_attempt <= 7,
days_since_release is not None and days_since_release >= 7,
])
if is_too_recent_to_check_for_old_episodes:
logger_background.info(f=f"skipping wanted media {media} since it's been released for a while and attempted recently")
continue
# media has been released (or it's missing its release date so try anyway) so create a task to try and fetch it
if not media.release_date or media.release_date <= today:
logger_background.info('Wanted {type}: {media}'.format(type=media_type, media=media))
# queue task for wanted media
Expand Down

0 comments on commit 76f677a

Please sign in to comment.