media-mgr 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- media_mgr-0.1.0/LICENSE +21 -0
- media_mgr-0.1.0/PKG-INFO +117 -0
- media_mgr-0.1.0/README.md +87 -0
- media_mgr-0.1.0/pyproject.toml +58 -0
- media_mgr-0.1.0/setup.cfg +4 -0
- media_mgr-0.1.0/src/__init__.py +6 -0
- media_mgr-0.1.0/src/media_mgr/__init__.py +0 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_comms_utility.py +89 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_exif_rename.py +92 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_gather.py +115 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_media_cfg.py +96 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_mover.py +74 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_paths_and_drives.py +175 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_plex_upgrade.py +162 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_search.py +109 -0
- media_mgr-0.1.0/src/media_mgr/cli/cli_server_cfg.py +95 -0
- media_mgr-0.1.0/src/media_mgr/comms_utility.py +146 -0
- media_mgr-0.1.0/src/media_mgr/exif_rename.py +153 -0
- media_mgr-0.1.0/src/media_mgr/gather.py +258 -0
- media_mgr-0.1.0/src/media_mgr/media_cfg.py +131 -0
- media_mgr-0.1.0/src/media_mgr/mover.py +117 -0
- media_mgr-0.1.0/src/media_mgr/paths_and_drives.py +356 -0
- media_mgr-0.1.0/src/media_mgr/plex_upgrade.py +310 -0
- media_mgr-0.1.0/src/media_mgr/search.py +154 -0
- media_mgr-0.1.0/src/media_mgr/server_cfg.py +136 -0
- media_mgr-0.1.0/src/media_mgr.egg-info/PKG-INFO +117 -0
- media_mgr-0.1.0/src/media_mgr.egg-info/SOURCES.txt +29 -0
- media_mgr-0.1.0/src/media_mgr.egg-info/dependency_links.txt +1 -0
- media_mgr-0.1.0/src/media_mgr.egg-info/entry_points.txt +14 -0
- media_mgr-0.1.0/src/media_mgr.egg-info/requires.txt +6 -0
- media_mgr-0.1.0/src/media_mgr.egg-info/top_level.txt +2 -0
media_mgr-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ed Waldner
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
media_mgr-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: media-mgr
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Media file search and categorization utilities
|
|
5
|
+
Author-email: Ed Waldner <waldevburry@proton.me>
|
|
6
|
+
Maintainer-email: Ed Waldner <waldevburry@proton.me>
|
|
7
|
+
Project-URL: Homepage, https://github.com/ew98/media-mgr
|
|
8
|
+
Project-URL: Documentation, https://github.com/ew98/media-mgr/wiki/MediaMgr
|
|
9
|
+
Project-URL: Issues, https://github.com/ew98/media-mgr/issues
|
|
10
|
+
Keywords: util,utility
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Natural Language :: English
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Operating System :: OS Independent
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: argcomplete
|
|
25
|
+
Requires-Dist: quickcolor
|
|
26
|
+
Requires-Dist: delayviewer
|
|
27
|
+
Requires-Dist: showexception
|
|
28
|
+
Requires-Dist: corecfg
|
|
29
|
+
Requires-Dist: pyexiv2
|
|
30
|
+
|
|
31
|
+
# Media-Mgr
|
|
32
|
+
|
|
33
|
+
**Media-Mgr** helps organize and search for media files on specified servers. Focus is currently PLEX based and includes PLEX server upgrade support on Ubuntu installs.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install **media-mgr**.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install media-mgr
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## CLI Controls
|
|
44
|
+
|
|
45
|
+
The following CLI controls are provided in this package for keeping track of media server categories and media server coordinates.
|
|
46
|
+
|
|
47
|
+
* mm-mediacfg
|
|
48
|
+
* mm-srvcfg
|
|
49
|
+
|
|
50
|
+
The following CLI controls assist with media server contents for search, organization, PLEX upgrades and miscellaneous tools (EXIF renamer)
|
|
51
|
+
|
|
52
|
+
* mm-util
|
|
53
|
+
* mm-path
|
|
54
|
+
* mm-search
|
|
55
|
+
* mm-gather
|
|
56
|
+
* mm-exif
|
|
57
|
+
* mm-plex-upg
|
|
58
|
+
|
|
59
|
+
Finally, these next sets of CLI controls are task specific for media management
|
|
60
|
+
|
|
61
|
+
* mount-drives
|
|
62
|
+
* search-plex
|
|
63
|
+
* move-plex
|
|
64
|
+
* upgrade-plex
|
|
65
|
+
* upgrade-plex-all
|
|
66
|
+
|
|
67
|
+
Each command has help syntax via CLI -h argument
|
|
68
|
+
|
|
69
|
+
For example:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
╰─ mount-drives -h
|
|
73
|
+
usage: mount-drives [-h] [--ipv4 <ipv4.addr>]
|
|
74
|
+
|
|
75
|
+
-.-.-. Mount Drives on Server utility
|
|
76
|
+
|
|
77
|
+
options:
|
|
78
|
+
-h, --help show this help message and exit
|
|
79
|
+
--ipv4 <ipv4.addr> Server IPV4
|
|
80
|
+
|
|
81
|
+
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
or
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
╰─ mm-gather -h
|
|
88
|
+
usage: mm-gather [-h] [-d] [--version]
|
|
89
|
+
{show.titles,show.all.titles,show.bundles,store.bundles,show.plex.n.worker.bundles,store.plex.n.worker.bundles}
|
|
90
|
+
...
|
|
91
|
+
|
|
92
|
+
-.-.-. Gathering for media manager
|
|
93
|
+
|
|
94
|
+
positional arguments:
|
|
95
|
+
{show.titles,show.all.titles,show.bundles,store.bundles,show.plex.n.worker.bundles,store.plex.n.worker.bundles}
|
|
96
|
+
show.titles Show retrieved titles
|
|
97
|
+
show.all.titles Show ALL retrieved titles
|
|
98
|
+
show.bundles Show title bundles
|
|
99
|
+
store.bundles Store title bundles
|
|
100
|
+
show.plex.n.worker.bundles
|
|
101
|
+
Show title bundles for Plex and Worker servers
|
|
102
|
+
store.plex.n.worker.bundles
|
|
103
|
+
Store title bundles for Plex and Worker servers
|
|
104
|
+
|
|
105
|
+
options:
|
|
106
|
+
-h, --help show this help message and exit
|
|
107
|
+
-d, --debug run with debug hooks enabled
|
|
108
|
+
--version top-level package version
|
|
109
|
+
|
|
110
|
+
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
|
117
|
+
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Media-Mgr
|
|
2
|
+
|
|
3
|
+
**Media-Mgr** helps organize and search for media files on specified servers. Focus is currently PLEX based and includes PLEX server upgrade support on Ubuntu installs.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Use the package manager [pip](https://pip.pypa.io/en/stable/) to install **media-mgr**.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install media-mgr
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## CLI Controls
|
|
14
|
+
|
|
15
|
+
The following CLI controls are provided in this package for keeping track of media server categories and media server coordinates.
|
|
16
|
+
|
|
17
|
+
* mm-mediacfg
|
|
18
|
+
* mm-srvcfg
|
|
19
|
+
|
|
20
|
+
The following CLI controls assist with media server contents for search, organization, PLEX upgrades and miscellaneous tools (EXIF renamer)
|
|
21
|
+
|
|
22
|
+
* mm-util
|
|
23
|
+
* mm-path
|
|
24
|
+
* mm-search
|
|
25
|
+
* mm-gather
|
|
26
|
+
* mm-exif
|
|
27
|
+
* mm-plex-upg
|
|
28
|
+
|
|
29
|
+
Finally, these next sets of CLI controls are task specific for media management
|
|
30
|
+
|
|
31
|
+
* mount-drives
|
|
32
|
+
* search-plex
|
|
33
|
+
* move-plex
|
|
34
|
+
* upgrade-plex
|
|
35
|
+
* upgrade-plex-all
|
|
36
|
+
|
|
37
|
+
Each command has help syntax via CLI -h argument
|
|
38
|
+
|
|
39
|
+
For example:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
╰─ mount-drives -h
|
|
43
|
+
usage: mount-drives [-h] [--ipv4 <ipv4.addr>]
|
|
44
|
+
|
|
45
|
+
-.-.-. Mount Drives on Server utility
|
|
46
|
+
|
|
47
|
+
options:
|
|
48
|
+
-h, --help show this help message and exit
|
|
49
|
+
--ipv4 <ipv4.addr> Server IPV4
|
|
50
|
+
|
|
51
|
+
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
or
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
╰─ mm-gather -h
|
|
58
|
+
usage: mm-gather [-h] [-d] [--version]
|
|
59
|
+
{show.titles,show.all.titles,show.bundles,store.bundles,show.plex.n.worker.bundles,store.plex.n.worker.bundles}
|
|
60
|
+
...
|
|
61
|
+
|
|
62
|
+
-.-.-. Gathering for media manager
|
|
63
|
+
|
|
64
|
+
positional arguments:
|
|
65
|
+
{show.titles,show.all.titles,show.bundles,store.bundles,show.plex.n.worker.bundles,store.plex.n.worker.bundles}
|
|
66
|
+
show.titles Show retrieved titles
|
|
67
|
+
show.all.titles Show ALL retrieved titles
|
|
68
|
+
show.bundles Show title bundles
|
|
69
|
+
store.bundles Store title bundles
|
|
70
|
+
show.plex.n.worker.bundles
|
|
71
|
+
Show title bundles for Plex and Worker servers
|
|
72
|
+
store.plex.n.worker.bundles
|
|
73
|
+
Store title bundles for Plex and Worker servers
|
|
74
|
+
|
|
75
|
+
options:
|
|
76
|
+
-h, --help show this help message and exit
|
|
77
|
+
-d, --debug run with debug hooks enabled
|
|
78
|
+
--version top-level package version
|
|
79
|
+
|
|
80
|
+
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
[MIT](https://choosealicense.com/licenses/mit/)
|
|
87
|
+
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools >= 61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "media-mgr"
|
|
7
|
+
description = "Media file search and categorization utilities"
|
|
8
|
+
readme = {file = "README.md", content-type = "text/markdown"}
|
|
9
|
+
authors = [{name = "Ed Waldner", email = "waldevburry@proton.me"},]
|
|
10
|
+
maintainers = [{name = "Ed Waldner", email = "waldevburry@proton.me"},]
|
|
11
|
+
# dynamic = ["version"]
|
|
12
|
+
version = "0.1.0"
|
|
13
|
+
requires-python = ">=3.9"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"argcomplete",
|
|
16
|
+
"quickcolor",
|
|
17
|
+
"delayviewer",
|
|
18
|
+
"showexception",
|
|
19
|
+
"corecfg",
|
|
20
|
+
"pyexiv2",
|
|
21
|
+
]
|
|
22
|
+
keywords = [
|
|
23
|
+
"util", "utility"
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 3 - Alpha",
|
|
27
|
+
"Environment :: Console",
|
|
28
|
+
"Intended Audience :: Developers",
|
|
29
|
+
"License :: OSI Approved :: MIT License",
|
|
30
|
+
"Natural Language :: English",
|
|
31
|
+
"Programming Language :: Python :: 3.10",
|
|
32
|
+
"Programming Language :: Python :: 3.11",
|
|
33
|
+
"Programming Language :: Python :: 3.12",
|
|
34
|
+
"Operating System :: OS Independent",
|
|
35
|
+
"Topic :: Utilities",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
Homepage = "https://github.com/ew98/media-mgr"
|
|
40
|
+
Documentation = "https://github.com/ew98/media-mgr/wiki/MediaMgr"
|
|
41
|
+
Issues = "https://github.com/ew98/media-mgr/issues"
|
|
42
|
+
|
|
43
|
+
[project.scripts]
|
|
44
|
+
mm-mediacfg = "media_mgr.cli.cli_media_cfg:cli"
|
|
45
|
+
mm-srvcfg = "media_mgr.cli.cli_server_cfg:cli"
|
|
46
|
+
mm-util = "media_mgr.cli.cli_comms_utility:cli"
|
|
47
|
+
mm-path = "media_mgr.cli.cli_paths_and_drives:cli"
|
|
48
|
+
mm-search = "media_mgr.cli.cli_search:cli"
|
|
49
|
+
mm-gather = "media_mgr.cli.cli_gather:cli"
|
|
50
|
+
mm-exif = "media_mgr.cli.cli_exif_rename:cli"
|
|
51
|
+
mm-plex-upg = "media_mgr.cli.cli_plex_upgrade:cli"
|
|
52
|
+
|
|
53
|
+
mount-drives = "media_mgr.cli.cli_paths_and_drives:cli_mount_drives"
|
|
54
|
+
search-plex = "media_mgr.cli.cli_search:cli_search_plex"
|
|
55
|
+
move-plex = "media_mgr.cli.cli_mover:cli_move_plex"
|
|
56
|
+
upgrade-plex = "media_mgr.cli.cli_plex_upgrade:cli_plex_upgrade"
|
|
57
|
+
upgrade-plex-all = "media_mgr.cli.cli_plex_upgrade:cli_plex_upgrade_all_servers"
|
|
58
|
+
|
|
File without changes
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ------------------------------------------------------------------------------------------------------
|
|
3
|
+
# -- CLI for Comms Utility Methods
|
|
4
|
+
# ------------------------------------------------------------------------------------------------------
|
|
5
|
+
# ======================================================================================================
|
|
6
|
+
|
|
7
|
+
# PYTHON_ARGCOMPLETE_OK
|
|
8
|
+
import argcomplete, argparse
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
from quickcolor.color_def import color
|
|
15
|
+
from showexception.showexception import exception_details
|
|
16
|
+
|
|
17
|
+
from ..comms_utility import run_cmd, is_server_active
|
|
18
|
+
|
|
19
|
+
# ------------------------------------------------------------------------------------------------------
|
|
20
|
+
# ------------------------------------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
def cli():
|
|
23
|
+
try:
|
|
24
|
+
parser = argparse.ArgumentParser(
|
|
25
|
+
description=f'{"-." * 3} {color.CBLUE2}Comms {color.CYELLOW2}Utilities {color.CEND}for media manager',
|
|
26
|
+
epilog='-.' * 40)
|
|
27
|
+
|
|
28
|
+
parser.add_argument('--version', action="store_true", help='top-level package version')
|
|
29
|
+
|
|
30
|
+
parser.add_argument( '--ipv4', metavar='<address>',
|
|
31
|
+
default=None, help='IPV4 to server')
|
|
32
|
+
|
|
33
|
+
parser.add_argument('-d', '--debug', action="store_true",
|
|
34
|
+
help='run with debug hooks enabled')
|
|
35
|
+
|
|
36
|
+
subparsers = parser.add_subparsers(dest='cmd')
|
|
37
|
+
|
|
38
|
+
p_dfh = subparsers.add_parser('dfh', help='List of drives (local or remote)')
|
|
39
|
+
|
|
40
|
+
p_ls = subparsers.add_parser('ls', help='List files in dir')
|
|
41
|
+
|
|
42
|
+
p_lsblk = subparsers.add_parser('lsblk', help='Show mountables')
|
|
43
|
+
|
|
44
|
+
p_serverChk = subparsers.add_parser('server.chk', help='Server ping')
|
|
45
|
+
|
|
46
|
+
argcomplete.autocomplete(parser)
|
|
47
|
+
args = parser.parse_args()
|
|
48
|
+
# print(args)
|
|
49
|
+
|
|
50
|
+
if len(sys.argv) == 1:
|
|
51
|
+
parser.print_help(sys.stderr)
|
|
52
|
+
sys.exit(1)
|
|
53
|
+
|
|
54
|
+
if args.version:
|
|
55
|
+
from importlib.metadata import version
|
|
56
|
+
import media_mgr
|
|
57
|
+
print(f'{color.CGREEN}{os.path.basename(sys.argv[0])}{color.CEND} resides in package ' + \
|
|
58
|
+
f'{color.CBLUE2}{media_mgr.__package__}{color.CEND} ' + \
|
|
59
|
+
f'version {color.CVIOLET2}{version("media_mgr")}{color.CEND} ...')
|
|
60
|
+
sys.exit(0)
|
|
61
|
+
|
|
62
|
+
if args.cmd == 'dfh':
|
|
63
|
+
# note quotes around grep argument
|
|
64
|
+
# -- grep on zsh target env does not work without quotes
|
|
65
|
+
cmd = 'df -h | grep "sd[b-z]" | sort -k 5'
|
|
66
|
+
print(run_cmd(ipv4 = args.ipv4, cmd = cmd,
|
|
67
|
+
cmdGet = True, debug = args.debug))
|
|
68
|
+
|
|
69
|
+
elif args.cmd == 'ls':
|
|
70
|
+
print(run_cmd(ipv4 = args.ipv4, cmd = "ls -als .",
|
|
71
|
+
cmdGet = True, debug = args.debug))
|
|
72
|
+
|
|
73
|
+
elif args.cmd == 'lsblk':
|
|
74
|
+
print(run_cmd(ipv4 = args.ipv4, cmd = "lsblk -b --json",
|
|
75
|
+
cmdGet = True, jsonOutput = True, debug = args.debug))
|
|
76
|
+
|
|
77
|
+
elif args.cmd == 'server.chk':
|
|
78
|
+
serverInfo = f'-- Server {color.CYELLOW}{args.ipv4}{color.CEND}'
|
|
79
|
+
if (is_server_active(ipv4 = args.ipv4)):
|
|
80
|
+
print(f'{serverInfo} is {color.CGREEN}active{color.CEND}!')
|
|
81
|
+
else:
|
|
82
|
+
print(f'{serverInfo} is {color.CRED2}dead{color.CEND}!')
|
|
83
|
+
|
|
84
|
+
except Exception as e:
|
|
85
|
+
exception_details(e, "Comms Utility CLI")
|
|
86
|
+
|
|
87
|
+
# ------------------------------------------------------------------------------------------------------
|
|
88
|
+
# ------------------------------------------------------------------------------------------------------
|
|
89
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ------------------------------------------------------------------------------------------------------
|
|
3
|
+
# -- CLI Methods for EXIF rename
|
|
4
|
+
# ------------------------------------------------------------------------------------------------------
|
|
5
|
+
# ======================================================================================================
|
|
6
|
+
|
|
7
|
+
# PYTHON_ARGCOMPLETE_OK
|
|
8
|
+
import argcomplete, argparse
|
|
9
|
+
from argcomplete.completers import EnvironCompleter # used for file/path arguments
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import os
|
|
13
|
+
import sys
|
|
14
|
+
|
|
15
|
+
from quickcolor.color_def import color
|
|
16
|
+
from showexception.showexception import exception_details
|
|
17
|
+
|
|
18
|
+
from ..exif_rename import show_path_info, show_exif_info, get_exif_datetime_original
|
|
19
|
+
from ..exif_rename import rename_all_jpg_in_path_to_exif_dates
|
|
20
|
+
from ..exif_rename import rename_all_jpg_in_all_sub_paths_to_exif_dates
|
|
21
|
+
|
|
22
|
+
# ------------------------------------------------------------------------------------------------------
|
|
23
|
+
# ------------------------------------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
def cli():
|
|
26
|
+
try:
|
|
27
|
+
parser = argparse.ArgumentParser(
|
|
28
|
+
description=f'{"-." * 3} {color.CYELLOW2}EXIF Rename {color.CEND}for media manager',
|
|
29
|
+
epilog='-.' * 40)
|
|
30
|
+
|
|
31
|
+
parser.add_argument('--version', action="store_true", help='top-level package version')
|
|
32
|
+
|
|
33
|
+
subparsers = parser.add_subparsers(dest='cmd')
|
|
34
|
+
|
|
35
|
+
p_showPathInfo = subparsers.add_parser('path.info', help='Show path info')
|
|
36
|
+
p_showPathInfo.add_argument("pathToFile", metavar='<path>',
|
|
37
|
+
help='Full path to JPG file').completer = EnvironCompleter
|
|
38
|
+
|
|
39
|
+
p_showExifInfo = subparsers.add_parser('exif.info', help='Show EXIF info')
|
|
40
|
+
p_showExifInfo.add_argument("pathToFile", metavar='<path>',
|
|
41
|
+
help='Full path to JPG file').completer = EnvironCompleter
|
|
42
|
+
|
|
43
|
+
p_getExifDateTimeOrig = subparsers.add_parser('get.datetime', help='Get EXIF date/time original')
|
|
44
|
+
p_getExifDateTimeOrig.add_argument("pathToFile", metavar='<path>',
|
|
45
|
+
help='Full path to JPG file').completer = EnvironCompleter
|
|
46
|
+
|
|
47
|
+
p_renameAllInPathToExif = subparsers.add_parser('to.exif.path', help='Rename all in path to EXIF')
|
|
48
|
+
p_renameAllInPathToExif.add_argument("pathToFolder", metavar='<path>',
|
|
49
|
+
help='Full path to JPG file folder').completer = EnvironCompleter
|
|
50
|
+
|
|
51
|
+
p_renameAllInSubPathsToExif = subparsers.add_parser('all.to.exif',
|
|
52
|
+
help='Rename all in path recursive to EXIF')
|
|
53
|
+
p_renameAllInSubPathsToExif.add_argument("pathToRootFolder", metavar='<path>',
|
|
54
|
+
help='Full path to JPG root folder').completer = EnvironCompleter
|
|
55
|
+
|
|
56
|
+
argcomplete.autocomplete(parser)
|
|
57
|
+
args = parser.parse_args()
|
|
58
|
+
# print(args)
|
|
59
|
+
|
|
60
|
+
if len(sys.argv) == 1:
|
|
61
|
+
parser.print_help(sys.stderr)
|
|
62
|
+
sys.exit(1)
|
|
63
|
+
|
|
64
|
+
if args.version:
|
|
65
|
+
from importlib.metadata import version
|
|
66
|
+
import media_mgr
|
|
67
|
+
print(f'{color.CGREEN}{os.path.basename(sys.argv[0])}{color.CEND} resides in package ' + \
|
|
68
|
+
f'{color.CBLUE2}{media_mgr.__package__}{color.CEND} ' + \
|
|
69
|
+
f'version {color.CVIOLET2}{version("media_mgr")}{color.CEND} ...')
|
|
70
|
+
sys.exit(0)
|
|
71
|
+
|
|
72
|
+
if args.cmd == 'path.info':
|
|
73
|
+
show_path_info(fullPathToFile = args.pathToFile)
|
|
74
|
+
|
|
75
|
+
elif args.cmd == 'exif.info':
|
|
76
|
+
show_exif_info(fullPathToFile = args.pathToFile)
|
|
77
|
+
|
|
78
|
+
elif args.cmd == 'get.datetime':
|
|
79
|
+
print(get_exif_datetime_original(fullPathToFile = args.pathToFile))
|
|
80
|
+
|
|
81
|
+
elif args.cmd == 'to.exif.path':
|
|
82
|
+
rename_all_jpg_in_path_to_exif_dates(pathToJpgs = args.pathToFolder)
|
|
83
|
+
|
|
84
|
+
elif args.cmd == 'all.to.exif':
|
|
85
|
+
rename_all_jpg_in_all_sub_paths_to_exif_dates(rootPath = args.pathToRootFolder)
|
|
86
|
+
|
|
87
|
+
except Exception as e:
|
|
88
|
+
exception_details(e, "EXIF File Rename CLI")
|
|
89
|
+
|
|
90
|
+
# ------------------------------------------------------------------------------------------------------
|
|
91
|
+
# ------------------------------------------------------------------------------------------------------
|
|
92
|
+
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
# ------------------------------------------------------------------------------------------------------
|
|
3
|
+
# -- CLI Methods for Gathering
|
|
4
|
+
# ------------------------------------------------------------------------------------------------------
|
|
5
|
+
# ======================================================================================================
|
|
6
|
+
|
|
7
|
+
# PYTHON_ARGCOMPLETE_OK
|
|
8
|
+
import argcomplete, argparse
|
|
9
|
+
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
from quickcolor.color_def import color
|
|
15
|
+
from showexception.showexception import exception_details
|
|
16
|
+
|
|
17
|
+
from ..server_cfg import get_available_server_types
|
|
18
|
+
|
|
19
|
+
from ..gather import show_retrieved_titles, show_all_retrieved_titles
|
|
20
|
+
from ..gather import show_title_bundles, store_title_bundles
|
|
21
|
+
from ..gather import store_title_bundles_plex_and_worker
|
|
22
|
+
|
|
23
|
+
# ------------------------------------------------------------------------------------------------------
|
|
24
|
+
# ------------------------------------------------------------------------------------------------------
|
|
25
|
+
|
|
26
|
+
def cli():
|
|
27
|
+
try:
|
|
28
|
+
parser = argparse.ArgumentParser(
|
|
29
|
+
description=f'{"-." * 3} {color.CYELLOW2}Gathering {color.CEND}for media manager',
|
|
30
|
+
epilog='-.' * 40)
|
|
31
|
+
|
|
32
|
+
parser.add_argument('-d', '--debug', action='store_true',
|
|
33
|
+
help='run with debug hooks enabled')
|
|
34
|
+
|
|
35
|
+
parser.add_argument('--version', action="store_true", help='top-level package version')
|
|
36
|
+
|
|
37
|
+
sp = parser.add_subparsers(dest='cmd')
|
|
38
|
+
|
|
39
|
+
sp_showRetrievedTitles = sp.add_parser('show.titles', help='Show retrieved titles')
|
|
40
|
+
sp_showRetrievedTitles.add_argument('ipv4', metavar='<ipv4.addr>', help='Server IPV4')
|
|
41
|
+
sp_showRetrievedTitles.add_argument('--type', choices=get_available_server_types(),
|
|
42
|
+
default='plex', metavar='<server.type>', help='Server type')
|
|
43
|
+
|
|
44
|
+
sp_showAllRetrievedTitles = sp.add_parser('show.all.titles', help='Show ALL retrieved titles')
|
|
45
|
+
|
|
46
|
+
sp_showTitleBundles = sp.add_parser('show.bundles', help='Show title bundles')
|
|
47
|
+
sp_showTitleBundles.add_argument('ipv4', metavar='<ipv4.addr>', help='Server IPV4')
|
|
48
|
+
sp_showTitleBundles.add_argument('--type', choices=get_available_server_types(),
|
|
49
|
+
default='plex', metavar='<server.type>', help='Server type')
|
|
50
|
+
|
|
51
|
+
sp_storeTitleBundles = sp.add_parser('store.bundles', help='Store title bundles')
|
|
52
|
+
sp_storeTitleBundles.add_argument('ipv4', metavar='<ipv4.addr>', help='Server IPV4')
|
|
53
|
+
sp_storeTitleBundles.add_argument('--type', choices=get_available_server_types(),
|
|
54
|
+
default='plex', metavar='<server.type>', help='Server type')
|
|
55
|
+
sp_storeTitleBundles.add_argument('--path',
|
|
56
|
+
default=None, metavar='<store.file.path>', help='Store file path')
|
|
57
|
+
|
|
58
|
+
sp_showTitleBundlesPlexWorker = sp.add_parser('show.plex.n.worker.bundles',
|
|
59
|
+
help='Show title bundles for Plex and Worker servers')
|
|
60
|
+
sp_showTitleBundlesPlexWorker.add_argument('ipv4_plex',
|
|
61
|
+
metavar='<ipv4.addr.plex.srvr>', help='Plex Server IPV4')
|
|
62
|
+
sp_showTitleBundlesPlexWorker.add_argument('ipv4_worker',
|
|
63
|
+
metavar='<ipv4.addr.worker.srvr>', help='Worker Server IPV4')
|
|
64
|
+
|
|
65
|
+
sp_storeTitleBundlesPlexWorker = sp.add_parser('store.plex.n.worker.bundles',
|
|
66
|
+
help='Store title bundles for Plex and Worker servers')
|
|
67
|
+
sp_storeTitleBundlesPlexWorker.add_argument('ipv4_plex',
|
|
68
|
+
metavar='<ipv4.addr.plex.srvr>', help='Plex Server IPV4')
|
|
69
|
+
sp_storeTitleBundlesPlexWorker.add_argument('ipv4_worker',
|
|
70
|
+
metavar='<ipv4.addr.worker.srvr>', help='Worker Server IPV4')
|
|
71
|
+
sp_storeTitleBundlesPlexWorker.add_argument('--path',
|
|
72
|
+
default=None, metavar='<store.file.path>', help='Store file path')
|
|
73
|
+
|
|
74
|
+
argcomplete.autocomplete(parser)
|
|
75
|
+
args = parser.parse_args()
|
|
76
|
+
# print(args)
|
|
77
|
+
|
|
78
|
+
if len(sys.argv) == 1:
|
|
79
|
+
parser.print_help(sys.stderr)
|
|
80
|
+
sys.exit(1)
|
|
81
|
+
|
|
82
|
+
if args.version:
|
|
83
|
+
from importlib.metadata import version
|
|
84
|
+
import media_mgr
|
|
85
|
+
print(f'{color.CGREEN}{os.path.basename(sys.argv[0])}{color.CEND} resides in package ' + \
|
|
86
|
+
f'{color.CBLUE2}{media_mgr.__package__}{color.CEND} ' + \
|
|
87
|
+
f'version {color.CVIOLET2}{version("media_mgr")}{color.CEND} ...')
|
|
88
|
+
sys.exit(0)
|
|
89
|
+
|
|
90
|
+
if args.cmd == 'show.titles':
|
|
91
|
+
show_retrieved_titles(ipv4 = args.ipv4, serverType = args.type)
|
|
92
|
+
|
|
93
|
+
elif args.cmd == 'show.all.titles':
|
|
94
|
+
show_all_retrieved_titles()
|
|
95
|
+
|
|
96
|
+
elif args.cmd == 'show.bundles':
|
|
97
|
+
show_title_bundles(ipv4 = args.ipv4, serverType = args.type)
|
|
98
|
+
|
|
99
|
+
elif args.cmd == 'store.bundles':
|
|
100
|
+
store_title_bundles(ipv4 = args.ipv4, serverType = args.type, storePath = args.path)
|
|
101
|
+
|
|
102
|
+
elif args.cmd == 'show.plex.n.worker.bundles':
|
|
103
|
+
show_title_bundles(ipv4 = args.ipv4_plex, serverType = 'plex')
|
|
104
|
+
show_title_bundles(ipv4 = args.ipv4_worker, serverType = 'worker')
|
|
105
|
+
|
|
106
|
+
elif args.cmd == 'store.plex.n.worker.bundles':
|
|
107
|
+
store_title_bundles_plex_and_worker(ipv4Plex = args.ipv4_plex,
|
|
108
|
+
ipv4Worker = args.ipv4_worker, storePath = args.path)
|
|
109
|
+
|
|
110
|
+
except Exception as e:
|
|
111
|
+
exception_details(e, "Media Title Gathering CLI", raw=True)
|
|
112
|
+
|
|
113
|
+
# ------------------------------------------------------------------------------------------------------
|
|
114
|
+
# ------------------------------------------------------------------------------------------------------
|
|
115
|
+
|