Skip to content

Commit

Permalink
Merge pull request #317 from lardbit/video-detect-tv
Browse files Browse the repository at this point in the history
Enable video detection for TV
  • Loading branch information
lardbit authored Dec 16, 2024
2 parents a257cf1 + 7f44967 commit 1048034
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Sometimes you want more control about which torrent is chosen for download.

## Blacklist & Retry a torrent

Sometimes a movie or tv show you download may be too low quality, wrong match, wrong sub-titles, or just completely fake.
Sometimes a movie or tv show you download may be too low quality, wrong match, wrong subtitles, or just completely fake.
You can tell nefarious to blacklist & delete that torrent and search again to find the next best option.

- click the **Status** tab on a movie or tv show
Expand Down
2 changes: 1 addition & 1 deletion src/nefarious/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@

UNPROCESSED_PATH = '.nefarious-unprocessed-downloads'

# container download path (or will be host in development)
# container download path (or will be the host in development)
INTERNAL_DOWNLOAD_PATH = os.environ.get('INTERNAL_DOWNLOAD_PATH', '/tmp')

# this is really just an indication to know if the nefarious container was volume mounted with access to the download path.
Expand Down
26 changes: 13 additions & 13 deletions src/nefarious/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,37 +170,37 @@ def completed_media_task():

logger_background.info('Media completed: {}'.format(media))

# run video detection, if enabled, on the relevant video files for movies, staging_path
if nefarious_settings.enable_video_detection and isinstance(media, WatchMovie):
# get the sub path (e.g. "movies/", "tv/') so we can move the data from staging
sub_path = str(
nefarious_settings.transmission_movie_download_dir if isinstance(media, WatchMovie)
else nefarious_settings.transmission_tv_download_dir
).lstrip('/')

# run video detection, if enabled, on movies and tv seasons
if nefarious_settings.enable_video_detection and isinstance(media, (WatchMovie, WatchTVSeason, WatchTVEpisode)):
logger_background.info("[VIDEO_DETECTION] verifying '{}'".format(media))
staging_path = os.path.join(
settings.INTERNAL_DOWNLOAD_PATH,
settings.UNPROCESSED_PATH,
nefarious_settings.transmission_movie_download_dir.lstrip('/'),
str(settings.INTERNAL_DOWNLOAD_PATH),
str(settings.UNPROCESSED_PATH),
sub_path,
torrent.name,
)
try:
if VideoDetect.has_valid_video_in_path(staging_path):
logger_background.info("[VIDEO_DETECTION] '{}' has valid video files".format(media))
else:
logger_background.error("[VIDEO_DETECTION] blacklisting '{}' because no valid video was found in {}".format(media, staging_path))
notification.send_message('blacklisting movie {} because no valid videos found ({}: {})'.format(media, torrent.name, media.transmission_torrent_hash))
notification.send_message('blacklisting media {} because no valid videos found ({}: {})'.format(media, torrent.name, media.transmission_torrent_hash))
blacklist_media_and_retry(media)
continue
except Exception as e:
logger_background.exception(e)
logger_background.error('error during video detection for {} with path {}'.format(media, staging_path))

# get the sub path (ie. "movies/", "tv/') so we can move the data from staging
sub_path = (
nefarious_settings.transmission_movie_download_dir if isinstance(media, WatchMovie)
else nefarious_settings.transmission_tv_download_dir
).lstrip('/')

# get the path and updated name for the data
new_path, new_name = get_media_new_path_and_name(media, torrent.name, len(torrent.files()) == 1)
relative_path = os.path.join(
sub_path, # i.e "movies" or "tv"
sub_path, # e.g. "movies" or "tv"
new_path or '',
)

Expand Down
2 changes: 1 addition & 1 deletion src/nefarious/video_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(self, video_path: str):

@classmethod
def has_valid_video_in_path(cls, path: str):
# TODO - this doesn't handle bundles (rar/zip/tar etc) since it won't find any "media" files
# NOTE this doesn't handle bundles (rar/zip/tar etc.) since it won't find any "media" files

files_to_verify = []

Expand Down

0 comments on commit 1048034

Please sign in to comment.