Skip to content

Commit

Permalink
Add some base tag conflicts solving
Browse files Browse the repository at this point in the history
  • Loading branch information
trickerer01 committed Sep 18, 2024
1 parent db6fa79 commit b75d27e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/bigstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@
'oviposition': 'eggs',
}

TAG_CONFLICTS = {
'solo': (['male_on_female', '1boy1girl', '2boys', '2futas', '2girls'], ['solo_female', 'solo_male']),
}

#
#
#########################################
3 changes: 2 additions & 1 deletion src/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from logger import Log
from path_util import file_already_exists, try_rename, is_file_being_used
from rex import re_media_filename, re_time, re_private_video
from tagger import filtered_tags, is_filtered_out_by_extra_tags, unite_separated_tags
from tagger import filtered_tags, is_filtered_out_by_extra_tags, solve_tag_conflicts, unite_separated_tags
from util import has_naming_flag, format_time, normalize_path, get_elapsed_time_i, get_time_seconds, extract_ext
from vinfo import VideoInfo, export_video_info, get_min_max_ids

Expand Down Expand Up @@ -128,6 +128,7 @@ async def scan_video(vi: VideoInfo) -> DownloadResult:
vi.comments = ('\n' + '\n\n'.join(comments_list) + '\n') if comments_list else ''
if Config.check_uploader and vi.uploader and vi.uploader not in tags_raw:
tags_raw.append(vi.uploader)
solve_tag_conflicts(vi, tags_raw)
if is_filtered_out_by_extra_tags(vi, tags_raw, Config.extra_tags, Config.id_sequence, vi.subfolder, extra_ids):
Log.info(f'Info: video {sname} is filtered out by{" outer" if scenario else ""} extra tags, skipping...')
return DownloadResult.FAIL_FILTERED_OUTER if scenario else DownloadResult.FAIL_SKIPPED
Expand Down
13 changes: 11 additions & 2 deletions src/tagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from typing import List, Optional, Collection, Iterable, MutableSequence, Union, Dict, Tuple

from bigstrings import TAG_ALIASES
from bigstrings import TAG_ALIASES, TAG_CONFLICTS
from config import Config
from defs import TAGS_CONCAT_CHAR
from logger import Log
Expand All @@ -20,7 +20,7 @@
from vinfo import VideoInfo

__all__ = (
'filtered_tags', 'get_matching_tag', 'extract_id_or_group', 'valid_extra_tag', 'is_filtered_out_by_extra_tags',
'filtered_tags', 'get_matching_tag', 'extract_id_or_group', 'valid_extra_tag', 'is_filtered_out_by_extra_tags', 'solve_tag_conflicts',
'valid_playlist_name', 'unite_separated_tags',
)

Expand Down Expand Up @@ -169,6 +169,15 @@ def trim_undersores(base_str: str) -> str:
return re_uscore_mult.sub('_', base_str).strip('_')


def solve_tag_conflicts(vi: VideoInfo, tags_raw: List[str]) -> None:
for ctag in TAG_CONFLICTS:
if ctag in tags_raw:
cposlist, cneglist = TAG_CONFLICTS[ctag]
if any(cp in tags_raw for cp in cposlist) and all(cn not in tags_raw for cn in cneglist):
Log.info(f'{vi.sname} is tagged with both \'{ctag}\' and \'{"/".join(cposlist)}\'! Removing \'{ctag}\' tag!')
tags_raw.remove(ctag)


def is_filtered_out_by_extra_tags(vi: VideoInfo, tags_raw: List[str], extra_tags: List[str],
id_seq: List[int], subfolder: str, id_seq_ex: List[int] = None) -> bool:
suc = True
Expand Down
2 changes: 1 addition & 1 deletion src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
APP_NAME = 'NM'
APP_VER_MAJOR = '1'
APP_VER_SUB = '8'
APP_REVISION = '442'
APP_REVISION = '443'
APP_VERSION = f'{APP_VER_MAJOR}.{APP_VER_SUB}.{APP_REVISION}'

#
Expand Down

0 comments on commit b75d27e

Please sign in to comment.