tvsd 1.3.2__tar.gz → 1.3.4__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.
- {tvsd-1.3.2 → tvsd-1.3.4}/PKG-INFO +39 -11
- {tvsd-1.3.2 → tvsd-1.3.4}/README.md +31 -7
- {tvsd-1.3.2 → tvsd-1.3.4}/pyproject.toml +32 -27
- tvsd-1.3.4/tvsd/.gitignore +3 -0
- tvsd-1.3.4/tvsd/__init__.py +30 -0
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/__main__.py +1 -1
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/actions.py +38 -23
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/cli.py +75 -43
- tvsd-1.3.4/tvsd/config.py +76 -0
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/download.py +14 -22
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/search.py +21 -25
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/_bu_ding_3.py +29 -35
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/_ify.py +3 -1
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/base.py +1 -1
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/olevod.py +1 -1
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/ssstv.py +2 -2
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/xiao_bao.py +1 -1
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/types/__init__.py +8 -7
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/types/episode.py +19 -20
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/types/season.py +16 -13
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/types/show.py +8 -7
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/utils.py +100 -23
- tvsd-1.3.2/tvsd/__init__.py +0 -32
- tvsd-1.3.2/tvsd/_variables.py +0 -29
- tvsd-1.3.2/tvsd/config.py +0 -170
- {tvsd-1.3.2 → tvsd-1.3.4}/LICENSE +0 -0
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/__init__.py +0 -0
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/_mov.py +0 -0
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/_template.py +0 -0
- {tvsd-1.3.2 → tvsd-1.3.4}/tvsd/sources/_ying_hua.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: tvsd
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.4
|
|
4
4
|
Summary: search and downloads TV and movies from websites
|
|
5
|
-
Home-page: https://github.com/sheepyy039/
|
|
5
|
+
Home-page: https://github.com/sheepyy039/TVSD.git
|
|
6
6
|
License: MIT
|
|
7
7
|
Keywords: download,tv,search,m3u8
|
|
8
8
|
Author: JYYYeung
|
|
@@ -14,17 +14,21 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
15
|
Classifier: Programming Language :: Python :: 3.10
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
18
|
Classifier: Topic :: Utilities
|
|
18
19
|
Requires-Dist: beautifulsoup4 (>=4.12.2,<5.0.0)
|
|
19
20
|
Requires-Dist: chinese-converter (>=1.1.1,<2.0.0)
|
|
20
21
|
Requires-Dist: cloudscraper (>=1.2.71,<2.0.0)
|
|
22
|
+
Requires-Dist: docstring-parser (>=0.15,<0.16)
|
|
23
|
+
Requires-Dist: dynaconf (>=3.2.4,<4.0.0)
|
|
21
24
|
Requires-Dist: m3u8-To-MP4 (>=0.1.11,<0.2.0)
|
|
22
25
|
Requires-Dist: multipledispatch (>=1.0.0,<2.0.0)
|
|
23
26
|
Requires-Dist: pytest (>=7.4.2,<8.0.0)
|
|
24
27
|
Requires-Dist: rich (>=13.6.0,<14.0.0)
|
|
25
28
|
Requires-Dist: typer (>=0.9.0,<0.10.0)
|
|
26
|
-
Project-URL: Changelog, https://github.com/sheepyy039/
|
|
27
|
-
Project-URL:
|
|
29
|
+
Project-URL: Changelog, https://github.com/sheepyy039/TVSD/blob/main/CHANGELOG.md
|
|
30
|
+
Project-URL: Documentation, https://sheepyy039.github.io/TVSD
|
|
31
|
+
Project-URL: Repository, https://github.com/sheepyy039/TVSD.git
|
|
28
32
|
Description-Content-Type: text/markdown
|
|
29
33
|
|
|
30
34
|
# TV Series Downloader [电视节目下载程序]
|
|
@@ -54,7 +58,7 @@ pip install tvsd
|
|
|
54
58
|
tvsd --help # Show available commands
|
|
55
59
|
```
|
|
56
60
|
|
|
57
|
-
### Update
|
|
61
|
+
### Update
|
|
58
62
|
|
|
59
63
|
```bash
|
|
60
64
|
pip install tvsd -U
|
|
@@ -73,16 +77,40 @@ More features coming soon, feel free to raise feature request or issues.
|
|
|
73
77
|
|
|
74
78
|
Contributions are welcomed, contribution methods and accurate details will be included very soon.
|
|
75
79
|
|
|
76
|
-
NOTE: Not not updated
|
|
77
|
-
|
|
78
80
|
```bash
|
|
79
|
-
git clone https://github.com/SheepYY039/
|
|
80
|
-
cd
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
git clone https://github.com/SheepYY039/tvsd.git
|
|
82
|
+
cd tvsd
|
|
83
|
+
make setup-dev-env # install pre-commit hooks
|
|
84
|
+
poetry install
|
|
85
|
+
# python3 setup.py install
|
|
83
86
|
cp .env.example .env # update .env according to your environment
|
|
84
87
|
```
|
|
85
88
|
|
|
89
|
+
### Versioning
|
|
90
|
+
|
|
91
|
+
This project uses [Commitizen](https://github.com/commitizen-tools/commitizen) to help release and versioning management.
|
|
92
|
+
|
|
93
|
+
- Fetch GitHub Version Tags: `make fetch-tags`
|
|
94
|
+
- Commit: `cz commit`
|
|
95
|
+
- Update Release Version: `make bump`
|
|
96
|
+
- Push GitHub Version Tag: `make push-tag`
|
|
97
|
+
|
|
98
|
+
### Publish
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
poetry config pypi-token.pypi <my-pypi-token>
|
|
102
|
+
poetry build
|
|
103
|
+
poetry publish
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Features
|
|
107
|
+
|
|
108
|
+
- [x] Search & Download Shows
|
|
109
|
+
- [ ] Track new episodes
|
|
110
|
+
- [ ] Web UI
|
|
111
|
+
- [ ] Docker
|
|
112
|
+
- [ ] Add Searching Progress Bar
|
|
113
|
+
|
|
86
114
|
## Inspired By and Credits to
|
|
87
115
|
|
|
88
116
|
- <https://github.com/hectorqin/reader>
|
|
@@ -25,7 +25,7 @@ pip install tvsd
|
|
|
25
25
|
tvsd --help # Show available commands
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
### Update
|
|
28
|
+
### Update
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
31
|
pip install tvsd -U
|
|
@@ -44,16 +44,40 @@ More features coming soon, feel free to raise feature request or issues.
|
|
|
44
44
|
|
|
45
45
|
Contributions are welcomed, contribution methods and accurate details will be included very soon.
|
|
46
46
|
|
|
47
|
-
NOTE: Not not updated
|
|
48
|
-
|
|
49
47
|
```bash
|
|
50
|
-
git clone https://github.com/SheepYY039/
|
|
51
|
-
cd
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
git clone https://github.com/SheepYY039/tvsd.git
|
|
49
|
+
cd tvsd
|
|
50
|
+
make setup-dev-env # install pre-commit hooks
|
|
51
|
+
poetry install
|
|
52
|
+
# python3 setup.py install
|
|
54
53
|
cp .env.example .env # update .env according to your environment
|
|
55
54
|
```
|
|
56
55
|
|
|
56
|
+
### Versioning
|
|
57
|
+
|
|
58
|
+
This project uses [Commitizen](https://github.com/commitizen-tools/commitizen) to help release and versioning management.
|
|
59
|
+
|
|
60
|
+
- Fetch GitHub Version Tags: `make fetch-tags`
|
|
61
|
+
- Commit: `cz commit`
|
|
62
|
+
- Update Release Version: `make bump`
|
|
63
|
+
- Push GitHub Version Tag: `make push-tag`
|
|
64
|
+
|
|
65
|
+
### Publish
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
poetry config pypi-token.pypi <my-pypi-token>
|
|
69
|
+
poetry build
|
|
70
|
+
poetry publish
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Features
|
|
74
|
+
|
|
75
|
+
- [x] Search & Download Shows
|
|
76
|
+
- [ ] Track new episodes
|
|
77
|
+
- [ ] Web UI
|
|
78
|
+
- [ ] Docker
|
|
79
|
+
- [ ] Add Searching Progress Bar
|
|
80
|
+
|
|
57
81
|
## Inspired By and Credits to
|
|
58
82
|
|
|
59
83
|
- <https://github.com/hectorqin/reader>
|
|
@@ -9,38 +9,38 @@ description = "search and downloads TV and movies from websites"
|
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
keywords = ["download", "tv", "search", "m3u8"]
|
|
11
11
|
license = "MIT"
|
|
12
|
-
version = "1.3.
|
|
12
|
+
version = "1.3.4"
|
|
13
13
|
classifiers = [
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
14
|
+
# 发展时期,常见的如下
|
|
15
|
+
# 3 - Alpha
|
|
16
|
+
# 4 - Beta
|
|
17
|
+
# 5 - Production/Stable
|
|
18
|
+
"Development Status :: 5 - Production/Stable",
|
|
19
|
+
# 开发的目标用户
|
|
20
|
+
# "Intended Audience :: Developers",
|
|
21
|
+
# 属于什么类型
|
|
22
|
+
# "Topic :: Software Development :: Build Tools",
|
|
23
|
+
"Topic :: Utilities",
|
|
24
|
+
# 许可证信息
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
# 目标 Python 版本
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.10",
|
|
29
|
+
# Environment
|
|
30
|
+
"Environment :: Console",
|
|
31
31
|
]
|
|
32
|
-
repository = "https://github.com/sheepyy039/
|
|
32
|
+
repository = "https://github.com/sheepyy039/TVSD.git"
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
packages = [
|
|
36
|
-
|
|
36
|
+
{ include = "tvsd*" }, # package names should match these glob patterns (["*"] by default)}
|
|
37
37
|
]
|
|
38
38
|
exclude = [".venv"]
|
|
39
39
|
|
|
40
40
|
[tool.poetry.urls]
|
|
41
41
|
# # Homepage = "https://example.com"
|
|
42
|
-
|
|
43
|
-
Changelog = "https://github.com/sheepyy039/
|
|
42
|
+
Documentation = "https://sheepyy039.github.io/TVSD"
|
|
43
|
+
Changelog = "https://github.com/sheepyy039/TVSD/blob/main/CHANGELOG.md"
|
|
44
44
|
|
|
45
45
|
[tool.poetry.scripts]
|
|
46
46
|
tvsd = "tvsd.__main__:main"
|
|
@@ -55,6 +55,9 @@ beautifulsoup4 = "^4.12.2"
|
|
|
55
55
|
cloudscraper = "^1.2.71"
|
|
56
56
|
chinese-converter = "^1.1.1"
|
|
57
57
|
pytest = "^7.4.2"
|
|
58
|
+
docstring-parser = "^0.15"
|
|
59
|
+
dynaconf = "^3.2.4"
|
|
60
|
+
|
|
58
61
|
|
|
59
62
|
[tool.poetry.group.dev.dependencies]
|
|
60
63
|
commitizen = "^3.10.0"
|
|
@@ -78,6 +81,8 @@ mkdocstrings = "^0.23.0"
|
|
|
78
81
|
mkdocstrings-python = "^1.7.3"
|
|
79
82
|
mkdocs-typer = "^0.0.3"
|
|
80
83
|
pytkdocs = { version = "^0.16.1", extras = ["google-style"] }
|
|
84
|
+
mkdocs-homepage-copier = "^1.0.0"
|
|
85
|
+
mkdocs-literate-nav = "^0.6.1"
|
|
81
86
|
|
|
82
87
|
|
|
83
88
|
[tool.isort]
|
|
@@ -86,13 +91,13 @@ profile = "black"
|
|
|
86
91
|
[tool.commitizen]
|
|
87
92
|
name = "cz_conventional_commits"
|
|
88
93
|
version_scheme = "pep440"
|
|
89
|
-
version = "1.3.
|
|
94
|
+
version = "1.3.4"
|
|
90
95
|
tag_format = "v$version"
|
|
91
96
|
version_files = [
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
97
|
+
"pyproject.toml:^version",
|
|
98
|
+
"VERSION",
|
|
99
|
+
"setup.py",
|
|
100
|
+
"pyproject.toml:version",
|
|
96
101
|
]
|
|
97
102
|
bump_message = "bump: version $current_version → $new_version"
|
|
98
103
|
update_changelog_on_bump = true
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
TVSD init module
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from importlib.metadata import PackageMetadata, metadata
|
|
6
|
+
|
|
7
|
+
from typer import Typer
|
|
8
|
+
|
|
9
|
+
_DISTRIBUTION_METADATA: PackageMetadata = metadata("tvsd")
|
|
10
|
+
__version__: str = _DISTRIBUTION_METADATA["Version"]
|
|
11
|
+
__app_name__ = "tvsd"
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
app = Typer(
|
|
15
|
+
name=__name__,
|
|
16
|
+
rich_markup_mode="rich",
|
|
17
|
+
invoke_without_command=True,
|
|
18
|
+
no_args_is_help=True,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
(
|
|
22
|
+
SUCCESS,
|
|
23
|
+
DIR_ERROR,
|
|
24
|
+
FILE_ERROR,
|
|
25
|
+
) = range(3)
|
|
26
|
+
|
|
27
|
+
ERRORS: dict[int, str] = {
|
|
28
|
+
DIR_ERROR: "config directory error",
|
|
29
|
+
FILE_ERROR: "config file error",
|
|
30
|
+
}
|
|
@@ -4,16 +4,19 @@ import os
|
|
|
4
4
|
import sys
|
|
5
5
|
from typing import List, Tuple
|
|
6
6
|
|
|
7
|
+
import typer
|
|
7
8
|
from rich.console import Console
|
|
8
9
|
from rich.table import Table
|
|
9
10
|
|
|
10
|
-
from tvsd
|
|
11
|
-
from tvsd.download import Download
|
|
12
|
-
from tvsd.search import SearchQuery
|
|
13
|
-
from tvsd.utils import check_dir_mounted, is_video
|
|
11
|
+
from tvsd import utils
|
|
14
12
|
|
|
13
|
+
from .config import settings
|
|
14
|
+
from .download import Download
|
|
15
|
+
from .search import SearchQuery
|
|
16
|
+
from .utils import dir_exists, is_video
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
|
|
19
|
+
def search_media_and_download(query: str, specials_only: bool = False) -> None:
|
|
17
20
|
"""Search for media and download
|
|
18
21
|
|
|
19
22
|
This function searches for media based on the given query string and downloads it.
|
|
@@ -25,21 +28,27 @@ def search_media_and_download(query: str, specials_only: bool = False):
|
|
|
25
28
|
query (str): query string
|
|
26
29
|
specials_only (bool): Download only specials episode. Defaults to False.
|
|
27
30
|
"""
|
|
28
|
-
|
|
29
|
-
if not
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
|
|
32
|
+
if not dir_exists(
|
|
33
|
+
path=settings.MEDIA_ROOT, create_if_not=settings.CREATE_MEDIA_ROOT
|
|
34
|
+
):
|
|
35
|
+
raise typer.Exit(code=1)
|
|
36
|
+
|
|
37
|
+
logging.debug("Media Root: %s", settings.MEDIA_ROOT)
|
|
38
|
+
|
|
39
|
+
if not dir_exists(path=settings.TEMP_ROOT, create_if_not=settings.CREATE_TEMP_ROOT):
|
|
40
|
+
raise typer.Exit(code=1)
|
|
41
|
+
|
|
42
|
+
logging.debug("Temp Root: %s", settings.TEMP_ROOT)
|
|
32
43
|
|
|
33
44
|
# Search
|
|
34
45
|
query_instance = SearchQuery(query)
|
|
35
46
|
logging.info("Searching for %s...", query)
|
|
36
|
-
query_instance.find_show(
|
|
47
|
+
query_instance.find_show()
|
|
37
48
|
|
|
38
49
|
# Download
|
|
39
50
|
download_instance = Download(
|
|
40
51
|
target=query_instance.chosen_show,
|
|
41
|
-
base_path=state_base_path(),
|
|
42
|
-
temp_path=state_temp_base_path(),
|
|
43
52
|
specials_only=specials_only,
|
|
44
53
|
)
|
|
45
54
|
logging.info("Starting %s guided download...", query_instance.chosen_show.title)
|
|
@@ -55,10 +64,10 @@ def list_shows_as_table(show_index=False) -> Tuple[List[str], int]:
|
|
|
55
64
|
Returns:
|
|
56
65
|
Tuple[List[str], int]: List of shows and number of shows
|
|
57
66
|
"""
|
|
58
|
-
|
|
59
|
-
logging.info("Checking if %s exists...",
|
|
60
|
-
if not os.path.isdir(
|
|
61
|
-
logging.error("%s does not exist! Nothing to list. Exiting...",
|
|
67
|
+
series_path = os.path.join(settings.MEDIA_ROOT, settings.SERIES_DIR)
|
|
68
|
+
logging.info("Checking if %s exists...", series_path)
|
|
69
|
+
if not os.path.isdir(series_path):
|
|
70
|
+
logging.error("%s does not exist! Nothing to list. Exiting...", series_path)
|
|
62
71
|
sys.exit()
|
|
63
72
|
|
|
64
73
|
console = Console()
|
|
@@ -68,27 +77,33 @@ def list_shows_as_table(show_index=False) -> Tuple[List[str], int]:
|
|
|
68
77
|
if show_index:
|
|
69
78
|
table = Table("#", "Name", "Year", "#Seasons", "#Episodes")
|
|
70
79
|
|
|
71
|
-
for show in os.listdir(os.path.join(
|
|
80
|
+
for show in os.listdir(os.path.join(settings.MEDIA_ROOT, settings.SERIES_DIR)):
|
|
72
81
|
num_files = 0
|
|
73
82
|
num_seasons = 0
|
|
74
|
-
if not os.path.isdir(
|
|
83
|
+
if not os.path.isdir(
|
|
84
|
+
os.path.join(settings.MEDIA_ROOT, settings.SERIES_DIR, show)
|
|
85
|
+
):
|
|
75
86
|
# Skip if not a directory
|
|
76
87
|
continue
|
|
77
88
|
# Iterate through seasons
|
|
78
89
|
for _first in os.listdir(
|
|
79
|
-
os.path.join(
|
|
90
|
+
os.path.join(settings.MEDIA_ROOT, settings.SERIES_DIR, show)
|
|
80
91
|
):
|
|
81
92
|
if os.path.isdir(
|
|
82
|
-
os.path.join(
|
|
93
|
+
os.path.join(settings.MEDIA_ROOT, settings.SERIES_DIR, show, _first)
|
|
83
94
|
):
|
|
84
95
|
num_seasons += 1
|
|
85
96
|
# Iterate through episodes
|
|
86
97
|
for _second in os.listdir(
|
|
87
|
-
os.path.join(
|
|
98
|
+
os.path.join(settings.MEDIA_ROOT, settings.SERIES_DIR, show, _first)
|
|
88
99
|
):
|
|
89
100
|
if os.path.isfile(
|
|
90
101
|
os.path.join(
|
|
91
|
-
|
|
102
|
+
settings.MEDIA_ROOT,
|
|
103
|
+
settings.SERIES_DIR,
|
|
104
|
+
show,
|
|
105
|
+
_first,
|
|
106
|
+
_second,
|
|
92
107
|
)
|
|
93
108
|
) and is_video(_second):
|
|
94
109
|
num_files += 1
|
|
@@ -99,7 +114,7 @@ def list_shows_as_table(show_index=False) -> Tuple[List[str], int]:
|
|
|
99
114
|
show_split = show.split(" ")
|
|
100
115
|
|
|
101
116
|
if len(show_split) > 1: # If show name has year
|
|
102
|
-
name = " ".join(show_split[:-1])
|
|
117
|
+
name: str = " ".join(show_split[:-1])
|
|
103
118
|
year = show_split[-1]
|
|
104
119
|
else:
|
|
105
120
|
name = show_split[0]
|
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
"""TVSD CLI entry point, main app module."""
|
|
2
|
+
|
|
2
3
|
import logging
|
|
3
4
|
import os
|
|
4
5
|
import shutil
|
|
5
6
|
from typing import Optional
|
|
6
7
|
|
|
7
8
|
import typer
|
|
9
|
+
|
|
10
|
+
# from docstring_parser import parse
|
|
8
11
|
from rich import print as rprint
|
|
9
12
|
|
|
10
|
-
from tvsd import __app_name__, __version__, app
|
|
11
|
-
from tvsd._variables import state_base_path, state_series_dir, state_temp_base_path
|
|
13
|
+
from tvsd import __app_name__, __version__, app
|
|
12
14
|
from tvsd.actions import list_shows_as_table, search_media_and_download
|
|
13
|
-
from tvsd.config import
|
|
15
|
+
from tvsd.config import register_validators, settings, validate_config
|
|
16
|
+
|
|
17
|
+
# from tvsd.config import apply_config, validate_config_file
|
|
14
18
|
from tvsd.utils import video_in_dir
|
|
15
19
|
|
|
20
|
+
from .utils import typer_easy_cli
|
|
21
|
+
|
|
16
22
|
|
|
17
23
|
def _version_callback(value: bool) -> None:
|
|
18
24
|
"""
|
|
@@ -29,8 +35,10 @@ def _version_callback(value: bool) -> None:
|
|
|
29
35
|
raise typer.Exit()
|
|
30
36
|
|
|
31
37
|
|
|
38
|
+
@typer_easy_cli
|
|
32
39
|
@app.callback()
|
|
33
|
-
def
|
|
40
|
+
def callback(
|
|
41
|
+
*,
|
|
34
42
|
_: Optional[bool] = typer.Option(
|
|
35
43
|
None,
|
|
36
44
|
"--version",
|
|
@@ -46,11 +54,14 @@ def main(
|
|
|
46
54
|
"-sd",
|
|
47
55
|
help="Specify the series directory, overrides config file",
|
|
48
56
|
),
|
|
49
|
-
|
|
57
|
+
media_root: Optional[str] = typer.Option(
|
|
50
58
|
None,
|
|
51
|
-
"--
|
|
52
|
-
"-
|
|
53
|
-
help="Specify the
|
|
59
|
+
"--media-root",
|
|
60
|
+
"-mr",
|
|
61
|
+
help="Specify the media root, overrides config file",
|
|
62
|
+
),
|
|
63
|
+
env: Optional[str] = typer.Option(
|
|
64
|
+
None, "--env", "-e", help="Specify the environment"
|
|
54
65
|
),
|
|
55
66
|
) -> None:
|
|
56
67
|
"""
|
|
@@ -60,29 +71,36 @@ def main(
|
|
|
60
71
|
It applies the config and sets the state of the application based on the provided options.
|
|
61
72
|
|
|
62
73
|
Args:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
74
|
+
verbose (bool, optional): Show verbose output.
|
|
75
|
+
series_dir (str, optional): Specify the series directory, overrides config file.
|
|
76
|
+
media_root (str, optional): Specify the media root, overrides config file.
|
|
77
|
+
env (str, optional): Specify the environment, overrides config file.
|
|
78
|
+
|
|
79
|
+
Returns:
|
|
80
|
+
None
|
|
67
81
|
"""
|
|
68
|
-
# initialize the config file before setting instance level
|
|
69
|
-
validate_config_file()
|
|
70
|
-
apply_config()
|
|
71
82
|
|
|
83
|
+
register_validators()
|
|
84
|
+
|
|
85
|
+
if env:
|
|
86
|
+
# change the environment to update proper settings
|
|
87
|
+
settings.setenv(env)
|
|
88
|
+
|
|
89
|
+
# update the dynaconf settings
|
|
72
90
|
if verbose:
|
|
73
91
|
typer.echo("Will write verbose output")
|
|
74
|
-
|
|
92
|
+
settings.set("verbose", True)
|
|
75
93
|
logging.basicConfig(level=logging.DEBUG)
|
|
76
94
|
else:
|
|
77
95
|
logging.basicConfig(level=logging.INFO)
|
|
78
96
|
|
|
79
97
|
if series_dir:
|
|
80
|
-
|
|
98
|
+
settings.set("series_dir", series_dir)
|
|
81
99
|
logging.info("Series directory set to %s", series_dir)
|
|
82
100
|
|
|
83
|
-
if
|
|
84
|
-
|
|
85
|
-
logging.info("
|
|
101
|
+
if media_root:
|
|
102
|
+
settings.set("media_root", media_root)
|
|
103
|
+
logging.info("Media Root set to %s", media_root)
|
|
86
104
|
|
|
87
105
|
|
|
88
106
|
@app.command()
|
|
@@ -94,19 +112,23 @@ def search(
|
|
|
94
112
|
"-s",
|
|
95
113
|
help="Download Specials Only",
|
|
96
114
|
),
|
|
97
|
-
):
|
|
98
|
-
"""
|
|
115
|
+
) -> None:
|
|
116
|
+
"""
|
|
117
|
+
Search for media and download
|
|
99
118
|
|
|
100
119
|
Args:
|
|
101
120
|
specials_only (Optional[bool], optional): Download only specials episode
|
|
102
121
|
query (str): query string
|
|
103
122
|
"""
|
|
104
|
-
|
|
123
|
+
|
|
124
|
+
# raises on first error found
|
|
125
|
+
settings.validators.validate()
|
|
126
|
+
|
|
105
127
|
search_media_and_download(query, specials_only)
|
|
106
128
|
|
|
107
129
|
|
|
108
130
|
@app.command()
|
|
109
|
-
def clean_temp():
|
|
131
|
+
def clean_temp() -> None:
|
|
110
132
|
"""
|
|
111
133
|
Cleans the temp directory.
|
|
112
134
|
|
|
@@ -117,33 +139,34 @@ def clean_temp():
|
|
|
117
139
|
Raises:
|
|
118
140
|
FileNotFoundError: If temp directory does not exist
|
|
119
141
|
"""
|
|
120
|
-
|
|
142
|
+
|
|
143
|
+
validate_config()
|
|
121
144
|
|
|
122
145
|
try:
|
|
123
|
-
dir_content = os.listdir(
|
|
146
|
+
dir_content = os.listdir(settings.TEMP_ROOT)
|
|
124
147
|
if len(dir_content) == 0:
|
|
125
148
|
raise FileNotFoundError
|
|
126
149
|
|
|
127
|
-
rprint(f"{
|
|
150
|
+
rprint(f"{settings.TEMP_ROOT} contents: ")
|
|
128
151
|
for item in dir_content:
|
|
129
152
|
rprint(f" {item}")
|
|
130
153
|
|
|
131
|
-
confirm = typer.prompt(
|
|
154
|
+
confirm: str = typer.prompt(
|
|
132
155
|
text="Do you want to delete all files in temp directory?",
|
|
133
156
|
type=str,
|
|
134
157
|
default="n",
|
|
135
158
|
)
|
|
136
159
|
if confirm.capitalize() == "Y":
|
|
137
|
-
shutil.rmtree(
|
|
138
|
-
os.mkdir(
|
|
160
|
+
shutil.rmtree(settings.TEMP_ROOT, ignore_errors=True)
|
|
161
|
+
os.mkdir(settings.TEMP_ROOT)
|
|
139
162
|
logging.info("All files deleted")
|
|
140
163
|
|
|
141
164
|
except FileNotFoundError:
|
|
142
|
-
logging.info("Temp directory %s does not exist",
|
|
165
|
+
logging.info("Temp directory %s does not exist", settings.TEMP_ROOT)
|
|
143
166
|
|
|
144
167
|
|
|
145
168
|
@app.command()
|
|
146
|
-
def list_shows():
|
|
169
|
+
def list_shows() -> None:
|
|
147
170
|
"""
|
|
148
171
|
List all shows in the database.
|
|
149
172
|
|
|
@@ -153,7 +176,7 @@ def list_shows():
|
|
|
153
176
|
|
|
154
177
|
|
|
155
178
|
@app.command()
|
|
156
|
-
def remove_show():
|
|
179
|
+
def remove_show() -> None:
|
|
157
180
|
"""List shows and remove selected show.
|
|
158
181
|
|
|
159
182
|
This function lists all the shows and their indices, prompts the user to select a show index to remove,
|
|
@@ -163,6 +186,7 @@ def remove_show():
|
|
|
163
186
|
Returns:
|
|
164
187
|
None
|
|
165
188
|
"""
|
|
189
|
+
|
|
166
190
|
shows, num_rows = list_shows_as_table(show_index=True)
|
|
167
191
|
|
|
168
192
|
while True:
|
|
@@ -176,7 +200,9 @@ def remove_show():
|
|
|
176
200
|
if typer.confirm(f"Will remove {shows[choice]}. Are you sure?", abort=True):
|
|
177
201
|
typer.echo("Removing show: " + shows[choice])
|
|
178
202
|
shutil.rmtree(
|
|
179
|
-
os.path.join(
|
|
203
|
+
os.path.join(
|
|
204
|
+
settings.MEDIA_ROOT, settings.SERIES_DIR, shows[choice]
|
|
205
|
+
)
|
|
180
206
|
)
|
|
181
207
|
typer.echo("Show removed")
|
|
182
208
|
break
|
|
@@ -185,7 +211,7 @@ def remove_show():
|
|
|
185
211
|
|
|
186
212
|
|
|
187
213
|
@app.command()
|
|
188
|
-
def print_state():
|
|
214
|
+
def print_state() -> None:
|
|
189
215
|
"""
|
|
190
216
|
Print the current state of the application.
|
|
191
217
|
|
|
@@ -194,14 +220,19 @@ def print_state():
|
|
|
194
220
|
Raises:
|
|
195
221
|
ConfigFileError: If the configuration file is invalid or missing.
|
|
196
222
|
"""
|
|
197
|
-
|
|
223
|
+
# validate_config()
|
|
224
|
+
|
|
225
|
+
data: dict = settings.as_dict(env=settings.current_env)
|
|
226
|
+
data.pop("POST_HOOKS", None)
|
|
227
|
+
data.pop("PRETTY_EXCEPTIONS_SHOW_LOCALS", None)
|
|
198
228
|
|
|
199
|
-
|
|
200
|
-
typer.echo(f"{key}: {value}")
|
|
229
|
+
typer.echo(data)
|
|
201
230
|
|
|
202
231
|
|
|
232
|
+
@typer_easy_cli
|
|
203
233
|
@app.command()
|
|
204
234
|
def clean_base(
|
|
235
|
+
*,
|
|
205
236
|
interactive: bool = typer.Option(
|
|
206
237
|
False,
|
|
207
238
|
"--interactive",
|
|
@@ -215,24 +246,25 @@ def clean_base(
|
|
|
215
246
|
help="Remove directories without videos",
|
|
216
247
|
),
|
|
217
248
|
target: str = typer.Option(
|
|
218
|
-
os.path.join(
|
|
249
|
+
os.path.join(settings.MEDIA_ROOT, settings.SERIES_DIR),
|
|
219
250
|
help="Target directory",
|
|
220
251
|
),
|
|
221
252
|
_no_confirm: bool = typer.Option(
|
|
222
253
|
False,
|
|
223
254
|
"--no-confirm",
|
|
224
255
|
),
|
|
225
|
-
):
|
|
256
|
+
) -> None:
|
|
226
257
|
"""
|
|
227
258
|
Remove empty directories in the base path
|
|
228
259
|
|
|
229
260
|
Args:
|
|
230
261
|
interactive (bool, optional): Whether to run in interactive mode. Defaults to False
|
|
231
262
|
greedy (bool, optional): Remove all directories without videos, even it they are not empty. Defaults to False.
|
|
232
|
-
target (str, optional): Target directory. Defaults to os.path.join(
|
|
263
|
+
target (str, optional): Target directory. Defaults to os.path.join(settings.MEDIA_ROOT, settings.SERIES_DIR).
|
|
233
264
|
_no_confirm (bool, optional): Don't show prompt to confirm actions. Defaults to False.
|
|
234
265
|
"""
|
|
235
|
-
|
|
266
|
+
validate_config()
|
|
267
|
+
|
|
236
268
|
if greedy and not _no_confirm:
|
|
237
269
|
typer.confirm(
|
|
238
270
|
"Greedy mode will remove directories without videos, even if they contain other content",
|
|
@@ -241,7 +273,7 @@ def clean_base(
|
|
|
241
273
|
|
|
242
274
|
for root, dirs, _ in os.walk(target, topdown=False):
|
|
243
275
|
for name in dirs:
|
|
244
|
-
path = os.path.join(root, name)
|
|
276
|
+
path: str = os.path.join(root, name)
|
|
245
277
|
if not os.listdir(path) and (
|
|
246
278
|
not interactive
|
|
247
279
|
or typer.confirm(f"Found Empty Directory, Remove {path}?")
|