Skip to content

Commit f64a343

Browse files
committed
2.4.005
1 parent d2650bf commit f64a343

30 files changed

+647
-164
lines changed

.github/README.md

+36-1
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,16 @@ To stop playing press Ctrl+C in either the terminal or mpv
9595
<details><summary>List all subcommands</summary>
9696

9797
$ library
98-
xk media library subcommands (v2.4.004)
98+
xk media library subcommands (v2.4.005)
9999

100100
Create database subcommands:
101101
╭───────────────┬────────────────────────────────────────────────────╮
102102
│ fsadd │ Add local media │
103103
├───────────────┼────────────────────────────────────────────────────┤
104104
│ tubeadd │ Add online video media (yt-dlp) │
105105
├───────────────┼────────────────────────────────────────────────────┤
106+
│ webadd │ Add open-directory media │
107+
├───────────────┼────────────────────────────────────────────────────┤
106108
│ galleryadd │ Add online gallery media (gallery-dl) │
107109
├───────────────┼────────────────────────────────────────────────────┤
108110
│ tabsadd │ Create a tabs database; Add URLs │
@@ -256,6 +258,11 @@ To stop playing press Ctrl+C in either the terminal or mpv
256258
│ nouns │ Unstructured text -> compound nouns (stdin) │
257259
╰────────────────┴─────────────────────────────────────────────╯
258260

261+
Other subcommands:
262+
╭───────────┬───────────╮
263+
│ webupdate │ webupdate │
264+
╰───────────┴───────────╯
265+
259266

260267
</details>
261268

@@ -575,6 +582,19 @@ BTW, for some cols like time_deleted you'll need to specify a where clause so th
575582
library tubeupdate tw.db --extra
576583

577584

585+
</details>
586+
587+
###### webadd
588+
589+
<details><summary>Add open-directory media</summary>
590+
591+
$ library webadd -h
592+
usage: library web-add [(--filesystem) | --video | --audio | --image | --text] DATABASE URL ...
593+
594+
Scan open directories
595+
596+
597+
578598
</details>
579599

580600
###### galleryadd
@@ -2573,6 +2593,21 @@ BTW, for some cols like time_deleted you'll need to specify a where clause so th
25732593
library process-audio --split-longer-than 36mins audiobook.m4b audiobook2.mp3
25742594

25752595

2596+
</details>
2597+
2598+
### Other subcommands
2599+
2600+
###### webupdate
2601+
2602+
<details><summary>webupdate</summary>
2603+
2604+
$ library webupdate -h
2605+
usage: library web-update DATABASE
2606+
2607+
Update saved open directories
2608+
2609+
2610+
25762611
</details>
25772612

25782613

pdm.lock

+33-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/test_gdl_backend.py

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ def create_args(test_name):
1616
verbose=2,
1717
profile={},
1818
extractor_config={},
19-
extra_playlist_data={},
20-
extra_media_data={},
2119
)
2220
args.db = connect(args)
2321
return args

xklb/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "2.4.004"
1+
__version__ = "2.4.005"

xklb/db_media.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,8 @@ def filter_args_sql(args, m_columns):
296296
{'and COALESCE(time_deleted,0) = 0' if 'time_deleted' in m_columns and "deleted" not in (getattr(args, 'sort_groups_by',None) or '') and "time_deleted" not in args.where else ''}
297297
{'AND (score IS NULL OR score > 7)' if 'score' in m_columns else ''}
298298
{'AND (upvote_ratio IS NULL OR upvote_ratio > 0.73)' if 'upvote_ratio' in m_columns else ''}
299-
{'AND COALESCE(time_downloaded,0) = 0' if args.online_media_only else ''}
300-
{'AND COALESCE(time_downloaded,1)!= 0 AND path not like "http%"' if args.local_media_only else ''}
299+
{'AND COALESCE(time_downloaded,0) = 0' if args.online_media_only and 'time_downloaded' in m_columns else ''}
300+
{'AND COALESCE(time_downloaded,1)!= 0 AND path not like "http%"' if args.local_media_only and 'time_downloaded' in m_columns else ''}
301301
"""
302302

303303

xklb/db_playlists.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def add(args, playlist_path: str, info: dict, check_subpath=False, extractor_key
134134
delete_subpath_playlists(args, playlist_path)
135135

136136
pl = consolidate(args, objects.dumbcopy(info))
137-
playlist = {**pl, "path": playlist_path, **args.extra_playlist_data}
137+
playlist = {**pl, "path": playlist_path}
138138
if extractor_key:
139139
playlist["extractor_key"] = extractor_key
140140
return _add(args, objects.dict_filter_bool(playlist))
@@ -240,6 +240,5 @@ def save_undownloadable(args, playlist_path) -> None:
240240
entry = {
241241
"path": playlist_path,
242242
"extractor_config": args.extractor_config,
243-
**args.extra_playlist_data,
244243
}
245244
_add(args, objects.dict_filter_bool(entry))

xklb/dl_extract.py

+22-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from xklb import gdl_backend, tube_backend, usage
55
from xklb.media import media_printer
6-
from xklb.utils import arg_utils, consts, db_utils, iterables, nums, objects, printing, processes, sql_utils
6+
from xklb.utils import arg_utils, consts, db_utils, iterables, nums, objects, printing, processes, sql_utils, web
77
from xklb.utils.consts import SC, DBType
88
from xklb.utils.log_utils import log
99

@@ -43,6 +43,14 @@ def parse_args():
4343
const=DBType.image,
4444
help="Use image downloader",
4545
)
46+
subp_profile.add_argument(
47+
"--filesystem",
48+
"--fs",
49+
action="store_const",
50+
dest="profile",
51+
const=DBType.filesystem,
52+
help="Use filesystem downloader",
53+
)
4654

4755
parser.add_argument(
4856
"--extractor-config",
@@ -54,14 +62,7 @@ def parse_args():
5462
help="Add key/value pairs to override or extend downloader configuration",
5563
)
5664
parser.add_argument("--download-archive")
57-
parser.add_argument("--extra-media-data", default={}, nargs=1, action=arg_utils.ArgparseDict, metavar="KEY=VALUE")
58-
parser.add_argument(
59-
"--extra-playlist-data",
60-
default={},
61-
nargs=1,
62-
action=arg_utils.ArgparseDict,
63-
metavar="KEY=VALUE",
64-
)
65+
6566
parser.add_argument("--safe", "-safe", action="store_true", help="Skip generic URLs")
6667
parser.add_argument("--same-domain", action="store_true", help="Choose a random domain to focus on")
6768

@@ -184,7 +185,7 @@ def construct_query(args) -> Tuple[str, dict]:
184185
FROM media m
185186
LEFT JOIN playlists p on p.id = m.playlist_id
186187
WHERE 1=1
187-
and COALESCE(m.time_downloaded,0) = 0
188+
{'and COALESCE(m.time_downloaded,0) = 0' if 'time_downloaded' in m_columns else ''}
188189
and COALESCE(m.time_deleted,0) = 0
189190
{'and COALESCE(p.time_deleted, 0) = 0' if 'time_deleted' in pl_columns else ''}
190191
and m.path like "http%"
@@ -273,7 +274,15 @@ def dl_download(args=None) -> None:
273274
if "limit" in args.defaults and "media" in args.db.table_names() and "webpath" in m_columns:
274275
if args.db.pop("SELECT 1 from media WHERE webpath is NULL and path in (select webpath from media) LIMIT 1"):
275276
with args.db.conn:
276-
args.db.conn.execute("DELETE from media WHERE webpath is NULL and path in (select webpath from media)")
277+
args.db.conn.execute(
278+
"""
279+
DELETE from media WHERE webpath is NULL
280+
AND path in (
281+
select webpath from media
282+
WHERE error IS NULL OR error != 'Media check failed'
283+
)
284+
"""
285+
)
277286

278287
args.blocklist_rules = []
279288
if "blocklist" in args.db.table_names():
@@ -330,6 +339,8 @@ def dl_download(args=None) -> None:
330339
tube_backend.download(args, m)
331340
elif args.profile == DBType.image:
332341
gdl_backend.download(args, m)
342+
elif args.profile == DBType.filesystem:
343+
web.download_url(m["path"], output_prefix=args.prefix)
333344
else:
334345
raise NotImplementedError
335346
except Exception:

0 commit comments

Comments
 (0)