Skip to content

Commit

Permalink
Rev 706: Re-enable -webm cmd argument (Videos options for GUI). Add…
Browse files Browse the repository at this point in the history
… `-mp4` cmd argument to prefer mp4 if there is more than 2 choices. Add `Prefer Original` GUI option to Videos combobox and make it the default. Disable Videos combobox for module it does nothing for
  • Loading branch information
trickerer01 committed Nov 3, 2024
1 parent c5c81ab commit d0b40a2
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 20 deletions.
10 changes: 6 additions & 4 deletions src/app_cmdargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
HELP_ARG_NOPROXY, HELP_ARG_PROXYNODOWN, HELP_ARG_HEADERS, HELP_ARG_COOKIES, HELP_ARG_PREFIX, HELP_ARG_DUMP_TAGS, HELP_ARG_DUMP_SOURCES,
HELP_ARG_DUMP_COMMENTS, HELP_ARG_DUMP_PER_ITEM, HELP_ARG_APPEND_SOURCE_AND_TAGS, HELP_ARG_TAGS, HELP_ARG_WARN_NON_EMPTY_FOLDER,
HELP_ARG_INCLUDE_PARCHI, HELP_ARG_CON_TIMEOUT, HELP_ARG_CON_RETRIES, HELP_ARG_GET_MAXID, HELP_ARG_CACHE_HTML_BLOAT, HELP_ARG_VERBOSE,
HELP_ARG_PREFER_WEBM, HELP_ARG_HEADER, HELP_ARG_COOKIE, HELP_ARG_MERGE_LISTS, HELP_ARG_REVERSE_DOWNLOAD_ORDER,
HELP_ARG_PREFER_WEBM, HELP_ARG_PREFER_MP4, HELP_ARG_HEADER, HELP_ARG_COOKIE, HELP_ARG_MERGE_LISTS, HELP_ARG_REVERSE_DOWNLOAD_ORDER,
)
from app_revision import APP_NAME, APP_VERSION
from app_validators import valid_thread_count, valid_date, valid_folder_path, valid_json, valid_kwarg, valid_proxy, valid_positive_int
Expand All @@ -45,11 +45,13 @@ def prepare_arglist(args: Sequence[str]) -> Namespace:
parser.add_argument('-module', default=MODULE_ABBR_RX, help=HELP_ARG_MODULE, choices=MODULE_CHOICES)
ex1 = parser.add_mutually_exclusive_group(required=False)
ex2 = parser.add_mutually_exclusive_group(required=False)
ex3 = parser.add_mutually_exclusive_group(required=False)
ex1.add_argument('-get_maxid', action=ACTION_STORE_TRUE, help=HELP_ARG_GET_MAXID)
parser.add_argument('-include_parchi', action=ACTION_STORE_TRUE, help=HELP_ARG_INCLUDE_PARCHI)
parser.add_argument('-skip_img', action=ACTION_STORE_TRUE, help=HELP_ARG_SKIP_IMAGES)
parser.add_argument('-skip_vid', action=ACTION_STORE_TRUE, help=HELP_ARG_SKIP_VIDEOS)
parser.add_argument('-webm', action=ACTION_STORE_TRUE, help=HELP_ARG_PREFER_WEBM)
ex2.add_argument('-webm', action=ACTION_STORE_TRUE, help=HELP_ARG_PREFER_WEBM)
ex2.add_argument('-mp4', action=ACTION_STORE_TRUE, help=HELP_ARG_PREFER_MP4)
parser.add_argument('-lowres', action=ACTION_STORE_TRUE, help=HELP_ARG_PREFER_LOWRES)
parser.add_argument('-mindate', metavar='#DD-MM-YYYY', help=HELP_ARG_MINDATE, type=valid_date)
parser.add_argument('-maxdate', metavar='#DD-MM-YYYY', help=HELP_ARG_MAXDATE, type=valid_date)
Expand All @@ -68,8 +70,8 @@ def prepare_arglist(args: Sequence[str]) -> Namespace:
parser.add_argument('-dump_tags', action=ACTION_STORE_TRUE, help=HELP_ARG_DUMP_TAGS)
parser.add_argument('-dump_sources', action=ACTION_STORE_TRUE, help=HELP_ARG_DUMP_SOURCES)
parser.add_argument('-dump_comments', action=ACTION_STORE_TRUE, help=HELP_ARG_DUMP_COMMENTS)
ex2.add_argument('-dump_per_item', action=ACTION_STORE_TRUE, help=HELP_ARG_DUMP_PER_ITEM)
ex2.add_argument('-merge_lists', action=ACTION_STORE_TRUE, help=HELP_ARG_MERGE_LISTS)
ex3.add_argument('-dump_per_item', action=ACTION_STORE_TRUE, help=HELP_ARG_DUMP_PER_ITEM)
ex3.add_argument('-merge_lists', action=ACTION_STORE_TRUE, help=HELP_ARG_MERGE_LISTS)
parser.add_argument('-append_info', action=ACTION_STORE_TRUE, help=HELP_ARG_APPEND_SOURCE_AND_TAGS)
parser.add_argument('-warn_nonempty', action=ACTION_STORE_TRUE, help=HELP_ARG_WARN_NON_EMPTY_FOLDER)
parser.add_argument('-verbose', action=ACTION_STORE_TRUE, help=HELP_ARG_VERBOSE)
Expand Down
11 changes: 8 additions & 3 deletions src/app_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ def _parse_args(self, args: Namespace, enable_preprocessing=True) -> None:
self.skip_images = args.skip_img or self.skip_images
self.skip_videos = args.skip_vid or self.skip_videos
self.prefer_webm = args.webm or self.prefer_webm
self.prefer_mp4 = args.mp4 or self.prefer_mp4
self.low_res = args.lowres or self.low_res
self.date_min = args.mindate or self.date_min
self.date_max = args.maxdate or self.date_max
Expand All @@ -703,9 +704,13 @@ def _parse_args(self, args: Namespace, enable_preprocessing=True) -> None:

def _solve_argument_conflicts(self) -> bool:
ret = False
if self.prefer_webm:
trace('Warning (W1): \'-webm\' option is deprecated and will be removed in near future. Ignored!')
ret = True
if not ProcModule.is_rs():
if self.prefer_webm:
trace(f'Warning (W1): \'-webm\' option is not available for \'{ProcModule.name().upper()}\' module. Ignored!')
ret = True
if self.prefer_mp4:
trace(f'Warning (W1): \'-mp4\' option is not available for \'{ProcModule.name().upper()}\' module. Ignored!')
ret = True
if not ProcModule.is_rx() and not ProcModule.is_en():
if self.include_parchi:
trace('Warning (W1): only RX and EN modules are able to collect parent posts. Disabled!')
Expand Down
1 change: 1 addition & 0 deletions src/app_download_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def __init__(self) -> None:
self.skip_images: bool = False
self.skip_videos: bool = False
self.prefer_webm: bool = False
self.prefer_mp4: bool = False
self.low_res: bool = False
self.date_min: str = DATE_MIN_DEFAULT
self.date_max: str = DATE_MAX_DEFAULT
Expand Down
13 changes: 6 additions & 7 deletions src/app_download_rs.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,19 +294,18 @@ def extract_local_addr(raw: str) -> str:
h = raw[idx1:raw.find('"', idx1 + 1)]
return h.replace('&', '&')

@staticmethod
def _extract_orig_link(raw_html: BeautifulSoup) -> str:
def _extract_orig_link(self, raw_html: BeautifulSoup) -> str:
content_div = raw_html.find('div', class_='content_push')
link_img = content_div.find('img') if content_div else None
link_mp4 = content_div.find('source', type='video/mp4') if content_div else None
link_wbm = content_div.find('source', type='video/webm') if content_div else None
link = link_mp4 or link_wbm or link_img
orig_href = str(link.get('src')) if link else ''
link_ori = raw_html.find('a', text='Original')
link = ((link_wbm or link_mp4) if self.prefer_webm else (link_mp4 or link_wbm) if self.prefer_mp4 else link_ori) or link_img
orig_href = str(link.get('src') or link.get('href')) if link else ''
return orig_href

@staticmethod
def _extract_sample_link(raw_html: BeautifulSoup) -> str:
orig_link = DownloaderRs._extract_orig_link(raw_html)
def _extract_sample_link(self, raw_html: BeautifulSoup) -> str:
orig_link = self._extract_orig_link(raw_html)
link = orig_link.replace('/images/', '/thumbnails/')
lsd_index = link.rfind('.')
link = link[:lsd_index] + '.jpg'
Expand Down
3 changes: 3 additions & 0 deletions src/app_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,9 @@ def update_widget_enabled_states() -> None:
if gi == Globals.COMBOBOX_PARCHI:
newstate = STATE_DISABLED if not ProcModule.is_rx() and not ProcModule.is_en() else gobject_orig_states[gi]
config_global(gi, state=newstate)
elif gi == Globals.COMBOBOX_VIDEOS:
newstate = STATE_DISABLED if not ProcModule.is_rs() else gobject_orig_states[gi]
config_global(gi, state=newstate)
elif gi in {Globals.FIELD_DATEMIN, Globals.FIELD_DATEMAX}:
newstate = STATE_DISABLED if ProcModule.is_rs() else gobject_orig_states[gi]
get_global(gi).set_state(newstate)
Expand Down
2 changes: 1 addition & 1 deletion src/app_gui_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ def create_base_window_widgets() -> None:
textvariable=StringVar(rootm(), '', CVARS[Options.VIDSETTING]))
register_global(Globals.COMBOBOX_VIDEOS, op_vid)
attach_tooltip(op_vid, TOOLTIP_VIDEOS)
op_vid.current(1)
op_vid.current(3)
op_vid.pack(padx=1, pady=3)
# Images
opframe_img = ttk.LabelFrame(opframe_main, text='Images')
Expand Down
4 changes: 2 additions & 2 deletions src/app_gui_defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
STICKY_HORIZONTAL = 'we'
STICKY_VERTICAL_W = 'wns'
# Combobox
OPTION_VALUES_VIDEOS = ('Don\'t download', 'Prefer MP4', 'Prefer Webm')
OPTION_VALUES_VIDEOS = ('Don\'t download', 'Prefer MP4', 'Prefer Webm', 'Prefer Original')
OPTION_VALUES_IMAGES = ('Don\'t download', 'Prefer low res', 'Prefer high res')
OPTION_VALUES_THREADING = ('1 Thread', '2 Threads', '3 Threads', '4 Threads', '5 Threads', '6 Threads', '7 Threads', '8 Threads')
OPTION_VALUES_PARCHI = ('Don\'t download', 'Download everything')
OPTION_VALUES_DOWNLOAD_ORDER = ('Default', 'Reverse')
OPTION_VALUES_PROXYTYPE = ('http', 'socks5')
OPTION_CMD_VIDEOS = ('-skip_vid', '', '-webm')
OPTION_CMD_VIDEOS = ('-skip_vid', '-mp4', '-webm', '')
OPTION_CMD_IMAGES = ('-skip_img', '-lowres', '')
OPTION_CMD_PARCHI = ('', '-include_parchi')
OPTION_CMD_DOWNLOAD_ORDER = ('', '-reverse')
Expand Down
3 changes: 2 additions & 1 deletion src/app_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
HELP_ARG_SKIP_VIDEOS = 'Skip all videos'
HELP_ARG_INCLUDE_PARCHI = 'Include all parent posts and all child posts (recursive, downloads whole chain, no filters)'
HELP_ARG_GET_MAXID = 'Print maximum id (for module) and exit'
HELP_ARG_PREFER_WEBM = '[DEPRECATED] Prefer webm over mp4 when possible'
HELP_ARG_PREFER_WEBM = 'Prefer webm over mp4 when possible'
HELP_ARG_PREFER_MP4 = 'Prefer mp4 over webm when possible'
HELP_ARG_PREFER_LOWRES = 'Prefer low resolution images over the originals'
HELP_ARG_MINDATE = 'Skip everything posted before this date, default is \'01-01-1970\''
HELP_ARG_MAXDATE = 'Skip everything posted after this date, default is \'<today>\''
Expand Down
4 changes: 2 additions & 2 deletions src/app_revision.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
APP_NAME = 'Ruxx'
APP_VER_MAJOR = '1'
APP_VER_SUB = '6'
APP_REVISION = '705'
APP_REVISION = '706'
APP_IS_BETA = False
APP_IS_BETA_TEXT = 'b' * APP_IS_BETA
APP_REV_DATE = '02 Nov 2024'
APP_REV_DATE = '03 Nov 2024'
APP_VERSION = f'{APP_VER_MAJOR}.{APP_VER_SUB} r{APP_REVISION}{APP_IS_BETA_TEXT}'

#
Expand Down

0 comments on commit d0b40a2

Please sign in to comment.