vsview-comp 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.
- vsview_comp-0.1.0/.gitignore +224 -0
- vsview_comp-0.1.0/LICENSE +21 -0
- vsview_comp-0.1.0/PKG-INFO +61 -0
- vsview_comp-0.1.0/README.md +15 -0
- vsview_comp-0.1.0/pyproject.toml +57 -0
- vsview_comp-0.1.0/src/vsview_comp/__init__.py +10 -0
- vsview_comp-0.1.0/src/vsview_comp/_metadata.py +4 -0
- vsview_comp-0.1.0/src/vsview_comp/models.py +204 -0
- vsview_comp-0.1.0/src/vsview_comp/plugin.py +839 -0
- vsview_comp-0.1.0/src/vsview_comp/py.typed +0 -0
- vsview_comp-0.1.0/src/vsview_comp/tmdb_api_key.txt +1 -0
- vsview_comp-0.1.0/src/vsview_comp/tmdb_tooltip.html.jinja +16 -0
- vsview_comp-0.1.0/src/vsview_comp/ui.py +984 -0
- vsview_comp-0.1.0/src/vsview_comp/utils.py +118 -0
- vsview_comp-0.1.0/src/vsview_comp/worker.py +550 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
|
|
204
|
+
# Ruff stuff:
|
|
205
|
+
.ruff_cache/
|
|
206
|
+
|
|
207
|
+
# PyPI configuration file
|
|
208
|
+
.pypirc
|
|
209
|
+
|
|
210
|
+
# Marimo
|
|
211
|
+
marimo/_static/
|
|
212
|
+
marimo/_lsp/
|
|
213
|
+
__marimo__/
|
|
214
|
+
|
|
215
|
+
# Streamlit
|
|
216
|
+
.streamlit/secrets.toml
|
|
217
|
+
|
|
218
|
+
# vsjet
|
|
219
|
+
.vsjet/
|
|
220
|
+
src/vsview/global_settings.json
|
|
221
|
+
|
|
222
|
+
# VapourSynth inventory files
|
|
223
|
+
vs_objects.inv
|
|
224
|
+
vs_fixed.inv
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Jaded Encoding Thaumaturgy
|
|
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.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vsview-comp
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A vsview plugin to make comparison backed by Slowpoke Pics
|
|
5
|
+
Project-URL: Source Code, https://github.com/Jaded-Encoding-Thaumaturgy/vs-view/tree/main/src/plugins/slowpics
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/Jaded-Encoding-Thaumaturgy/vs-view/issues
|
|
7
|
+
Project-URL: Contact, https://discord.gg/XTpc6Fa9eB
|
|
8
|
+
Author-email: Jimbo <17926797+Kapppa@users.noreply.github.com>, Vardë <ichunjo.le.terrible@gmail.com>
|
|
9
|
+
Maintainer-email: Vardë <ichunjo.le.terrible@gmail.com>, Jaded Encoding Thaumaturgy <jaded.encoding.thaumaturgy@gmail.com>
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2025 Jaded Encoding Thaumaturgy
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
in the Software without restriction, including without limitation the rights
|
|
17
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
furnished to do so, subject to the following conditions:
|
|
20
|
+
|
|
21
|
+
The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
copies or substantial portions of the Software.
|
|
23
|
+
|
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
SOFTWARE.
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
33
|
+
Classifier: Operating System :: OS Independent
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
38
|
+
Classifier: Typing :: Typed
|
|
39
|
+
Requires-Python: >=3.12
|
|
40
|
+
Requires-Dist: httpx>=0.28.1
|
|
41
|
+
Requires-Dist: jinja2>=3.1.6
|
|
42
|
+
Requires-Dist: pathvalidate
|
|
43
|
+
Requires-Dist: vsjetpack>=1.0.0
|
|
44
|
+
Requires-Dist: vsview[secrets]
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# vsview-comp
|
|
48
|
+
|
|
49
|
+
A [vsview](https://github.com/Jaded-Encoding-Thaumaturgy/vs-view) plugin to make comparison backed by Slowpoke Pics.
|
|
50
|
+
|
|
51
|
+
## Requirements
|
|
52
|
+
|
|
53
|
+
- [vsview](https://github.com/Jaded-Encoding-Thaumaturgy/vs-view)
|
|
54
|
+
- [vsjetpack](https://github.com/Jaded-Encoding-Thaumaturgy/vs-jetpack) 1.1.0 or later
|
|
55
|
+
- [httpx](https://github.com/encode/httpx)
|
|
56
|
+
|
|
57
|
+
## Installation
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install vsview-comp
|
|
61
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# vsview-comp
|
|
2
|
+
|
|
3
|
+
A [vsview](https://github.com/Jaded-Encoding-Thaumaturgy/vs-view) plugin to make comparison backed by Slowpoke Pics.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- [vsview](https://github.com/Jaded-Encoding-Thaumaturgy/vs-view)
|
|
8
|
+
- [vsjetpack](https://github.com/Jaded-Encoding-Thaumaturgy/vs-jetpack) 1.1.0 or later
|
|
9
|
+
- [httpx](https://github.com/encode/httpx)
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
pip install vsview-comp
|
|
15
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling", "versioningit"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vsview-comp"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "A vsview plugin to make comparison backed by Slowpoke Pics"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { file = "LICENSE" }
|
|
11
|
+
requires-python = ">=3.12"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Jimbo", email = "17926797+Kapppa@users.noreply.github.com" },
|
|
14
|
+
{ name = "Vardë", email = "ichunjo.le.terrible@gmail.com" },
|
|
15
|
+
]
|
|
16
|
+
maintainers = [
|
|
17
|
+
{ name = "Vardë", email = "ichunjo.le.terrible@gmail.com" },
|
|
18
|
+
{ name = "Jaded Encoding Thaumaturgy", email = "jaded.encoding.thaumaturgy@gmail.com" },
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
classifiers = [
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Programming Language :: Python :: 3",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Typing :: Typed",
|
|
29
|
+
]
|
|
30
|
+
dependencies = [
|
|
31
|
+
"vsview[secrets]",
|
|
32
|
+
"vsjetpack>=1.0.0",
|
|
33
|
+
"httpx>=0.28.1",
|
|
34
|
+
"pathvalidate",
|
|
35
|
+
"jinja2>=3.1.6",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.entry-points.vsview]
|
|
39
|
+
vsview_comp = "vsview_comp"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
"Source Code" = "https://github.com/Jaded-Encoding-Thaumaturgy/vs-view/tree/main/src/plugins/slowpics"
|
|
43
|
+
"Bug Tracker" = "https://github.com/Jaded-Encoding-Thaumaturgy/vs-view/issues"
|
|
44
|
+
"Contact" = "https://discord.gg/XTpc6Fa9eB"
|
|
45
|
+
|
|
46
|
+
[tool.uv.sources]
|
|
47
|
+
vsview = { workspace = true }
|
|
48
|
+
|
|
49
|
+
[tool.hatch.version]
|
|
50
|
+
source = "versioningit"
|
|
51
|
+
|
|
52
|
+
[tool.versioningit.vcs]
|
|
53
|
+
match = ["comp/v*"]
|
|
54
|
+
default-tag = "comp/v0.0.0"
|
|
55
|
+
|
|
56
|
+
[tool.versioningit.tag2version]
|
|
57
|
+
rmprefix = "comp/v"
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
from collections.abc import Sequence
|
|
5
|
+
from logging import getLogger
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any, Literal, NamedTuple, Self
|
|
8
|
+
|
|
9
|
+
from jetpytools import classproperty
|
|
10
|
+
from pydantic import BaseModel, ConfigDict, Field, ValidationError
|
|
11
|
+
|
|
12
|
+
logger = getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ComparisonImage(NamedTuple):
|
|
16
|
+
path: Path
|
|
17
|
+
pict_type: str
|
|
18
|
+
frame_no: int
|
|
19
|
+
timestamp: str
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ComparisonSource(NamedTuple):
|
|
23
|
+
name: str
|
|
24
|
+
images: Sequence[ComparisonImage]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class TMDBGenre(BaseModel):
|
|
28
|
+
id: int
|
|
29
|
+
name: str
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class TMDBProductionCountry(BaseModel):
|
|
33
|
+
iso_3166_1: str = ""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class LoggedBaseModel(BaseModel):
|
|
37
|
+
@classmethod
|
|
38
|
+
def validate_logged(cls, obj: Any, log_context: str) -> Self | None:
|
|
39
|
+
try:
|
|
40
|
+
return super().model_validate(obj)
|
|
41
|
+
except ValidationError as e:
|
|
42
|
+
logger.warning("Ignoring invalid payload in %s: %s", log_context, e)
|
|
43
|
+
logger.debug("Payload validation traceback", exc_info=True)
|
|
44
|
+
return None
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class TMDBTitleData(LoggedBaseModel):
|
|
48
|
+
model_config = ConfigDict(extra="allow")
|
|
49
|
+
|
|
50
|
+
id: int
|
|
51
|
+
name: str = ""
|
|
52
|
+
title: str = ""
|
|
53
|
+
original_name: str | None = None
|
|
54
|
+
original_title: str | None = None
|
|
55
|
+
original_language: str | None = None
|
|
56
|
+
origin_country: list[str] = Field(default_factory=list)
|
|
57
|
+
production_countries: list[TMDBProductionCountry] = Field(default_factory=list)
|
|
58
|
+
first_air_date: str | None = None
|
|
59
|
+
release_date: str | None = None
|
|
60
|
+
poster_path: str | None = None
|
|
61
|
+
overview: str | None = None
|
|
62
|
+
vote_average: float | None = None
|
|
63
|
+
vote_count: int | None = None
|
|
64
|
+
popularity: float | None = None
|
|
65
|
+
genre_ids: list[int] = Field(default_factory=list)
|
|
66
|
+
genres: list[TMDBGenre] = Field(default_factory=list)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class TMDBPayload(LoggedBaseModel):
|
|
70
|
+
results: list[TMDBTitleData] = Field(default_factory=list)
|
|
71
|
+
genres: list[TMDBGenre] = Field(default_factory=list)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
class TMDBTooltipData(BaseModel):
|
|
75
|
+
header: str
|
|
76
|
+
original_name: str
|
|
77
|
+
genres: str
|
|
78
|
+
language: str
|
|
79
|
+
country: str
|
|
80
|
+
release_date: str
|
|
81
|
+
rating: str
|
|
82
|
+
popularity: str
|
|
83
|
+
tmdb_id: str
|
|
84
|
+
overview: str
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class TMDBTitle(BaseModel):
|
|
88
|
+
model_config = ConfigDict(ignored_types=(classproperty,))
|
|
89
|
+
|
|
90
|
+
data: TMDBTitleData
|
|
91
|
+
media_type: Literal["tv", "movie"]
|
|
92
|
+
genres: list[str] = Field(default_factory=list)
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def id(self) -> str:
|
|
96
|
+
"""TMDB ID"""
|
|
97
|
+
return str(self.data.id)
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def name(self) -> str:
|
|
101
|
+
"""Title name"""
|
|
102
|
+
return self.data.name if self.media_type == "tv" else self.data.title
|
|
103
|
+
|
|
104
|
+
@property
|
|
105
|
+
def original_name(self) -> str:
|
|
106
|
+
"""Original title name"""
|
|
107
|
+
return self.data.original_name or self.data.original_title or "-"
|
|
108
|
+
|
|
109
|
+
@property
|
|
110
|
+
def year(self) -> str:
|
|
111
|
+
"""Release year"""
|
|
112
|
+
release_date = self.data.first_air_date if self.media_type == "tv" else self.data.release_date
|
|
113
|
+
return (release_date or "0000")[:4]
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def media_tag(self) -> str:
|
|
117
|
+
"""Media tag (TV or Movie)"""
|
|
118
|
+
return self.media_type.upper()
|
|
119
|
+
|
|
120
|
+
@property
|
|
121
|
+
def language(self) -> str:
|
|
122
|
+
"""Original language"""
|
|
123
|
+
return (self.data.original_language or "-").upper()
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def country(self) -> str:
|
|
127
|
+
"""Original country"""
|
|
128
|
+
return (
|
|
129
|
+
", ".join(
|
|
130
|
+
[c for c in self.data.origin_country if c]
|
|
131
|
+
or [c.iso_3166_1 for c in self.data.production_countries if c.iso_3166_1]
|
|
132
|
+
)
|
|
133
|
+
or "-"
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def release_date(self) -> str:
|
|
138
|
+
"""Release date"""
|
|
139
|
+
return (self.data.first_air_date or self.data.release_date or "-").strip()
|
|
140
|
+
|
|
141
|
+
@property
|
|
142
|
+
def rating(self) -> str:
|
|
143
|
+
"""Rating"""
|
|
144
|
+
if self.data.vote_average is not None and self.data.vote_count is not None and self.data.vote_count > 0:
|
|
145
|
+
return f"{self.data.vote_average:.1f} ({self.data.vote_count} votes)"
|
|
146
|
+
else:
|
|
147
|
+
return "Not enough ratings"
|
|
148
|
+
|
|
149
|
+
@property
|
|
150
|
+
def popularity(self) -> str:
|
|
151
|
+
"""Popularity"""
|
|
152
|
+
return f"{self.data.popularity:.2f}" if self.data.popularity is not None else "-"
|
|
153
|
+
|
|
154
|
+
@property
|
|
155
|
+
def overview(self) -> str:
|
|
156
|
+
"""Overview"""
|
|
157
|
+
return (self.data.overview or "-").strip()
|
|
158
|
+
|
|
159
|
+
@property
|
|
160
|
+
def tooltip_data(self) -> TMDBTooltipData:
|
|
161
|
+
overview = self.overview
|
|
162
|
+
if len(overview) > 480:
|
|
163
|
+
overview = f"{overview[:477].rstrip()}..."
|
|
164
|
+
|
|
165
|
+
return TMDBTooltipData(
|
|
166
|
+
header=f"{self.name} ({self.year}) [{self.media_tag}]",
|
|
167
|
+
original_name=self.original_name,
|
|
168
|
+
genres=", ".join(self.genres) if self.genres else "-",
|
|
169
|
+
language=self.language,
|
|
170
|
+
country=self.country,
|
|
171
|
+
release_date=self.release_date,
|
|
172
|
+
rating=self.rating,
|
|
173
|
+
popularity=self.popularity,
|
|
174
|
+
tmdb_id=self.id,
|
|
175
|
+
overview=overview,
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
@classproperty
|
|
179
|
+
@classmethod
|
|
180
|
+
def supported_format_fields(cls) -> tuple[str, ...]:
|
|
181
|
+
return ("id", "name", "original_name", "year", "media_tag", "language", "country", "release_date")
|
|
182
|
+
|
|
183
|
+
@classproperty
|
|
184
|
+
@classmethod
|
|
185
|
+
def format_hints(cls) -> dict[str, str]:
|
|
186
|
+
hints = dict[str, str]()
|
|
187
|
+
for field in cls.supported_format_fields:
|
|
188
|
+
if not isinstance((prop := getattr(cls, field, None)), property):
|
|
189
|
+
logger.warning("Field %s is not a property", field)
|
|
190
|
+
continue
|
|
191
|
+
|
|
192
|
+
hints[field] = (prop.fget.__doc__ or "").strip()
|
|
193
|
+
return hints
|
|
194
|
+
|
|
195
|
+
def format_name(self, fmt: str, **extra: str) -> str:
|
|
196
|
+
"""Format a name string using available TMDB fields and extra context."""
|
|
197
|
+
|
|
198
|
+
return fmt.format_map(
|
|
199
|
+
defaultdict(
|
|
200
|
+
str,
|
|
201
|
+
**{field: str(getattr(self, field)) for field in self.supported_format_fields},
|
|
202
|
+
**extra,
|
|
203
|
+
)
|
|
204
|
+
)
|