Skip to content

Commit 092d27b

Browse files
Python 3.13 (#259)
* lchown in one cmd * update dependencies and python 3.13 support * refactoring * update dependencies
1 parent 46a3f43 commit 092d27b

File tree

13 files changed

+1598
-1608
lines changed

13 files changed

+1598
-1608
lines changed

.eslintrc.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [ubuntu-latest, macos-latest, windows-latest]
16-
python-version: [ '3.9', '3.10', '3.11', '3.12' ]
16+
python-version: [ '3.10', '3.11', '3.12', '3.13' ]
1717
steps:
1818
- name: Checkout
1919
uses: actions/checkout@v4
@@ -31,7 +31,7 @@ jobs:
3131
- name: Install poetry
3232
uses: abatilo/actions-poetry@v2
3333
with:
34-
poetry-version: '1.8.3'
34+
poetry-version: '1.8.4'
3535

3636
- name: Install Go
3737
uses: actions/setup-go@v5
@@ -77,7 +77,7 @@ jobs:
7777
- name: Set up Python
7878
uses: actions/setup-python@v5
7979
with:
80-
python-version: '3.12'
80+
python-version: '3.13'
8181

8282
- name: Display Python version
8383
run: python --version
@@ -102,7 +102,7 @@ jobs:
102102
- name: Install poetry
103103
uses: abatilo/actions-poetry@v2
104104
with:
105-
poetry-version: '1.8.3'
105+
poetry-version: '1.8.4'
106106

107107
- uses: pnpm/action-setup@v3
108108
with:
@@ -161,15 +161,15 @@ jobs:
161161
- name: Set up Python
162162
uses: actions/setup-python@v5
163163
with:
164-
python-version: '3.12'
164+
python-version: '3.13'
165165

166166
- name: Display Python version
167167
run: python --version
168168

169169
- name: install poetry
170170
uses: abatilo/actions-poetry@v2
171171
with:
172-
poetry-version: '1.8.3'
172+
poetry-version: '1.8.4'
173173

174174
- name: create tag from pyproject version on change.
175175
id: auto-tag
@@ -206,15 +206,15 @@ jobs:
206206
- name: Set up Python
207207
uses: actions/setup-python@v5
208208
with:
209-
python-version: '3.12'
209+
python-version: '3.13'
210210

211211
- name: Display Python version
212212
run: python --version
213213

214214
- name: Install poetry
215215
uses: abatilo/actions-poetry@v2
216216
with:
217-
poetry-version: '1.8.3'
217+
poetry-version: '1.8.4'
218218

219219
- name: Install Go
220220
uses: actions/setup-go@v5

eslint.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import globals from 'globals'
2+
import pluginJs from '@eslint/js'
3+
4+
export default [
5+
{ languageOptions: { globals: globals.browser } },
6+
pluginJs.configs.recommended,
7+
]

namer/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020

2121
import namer.metadataapi
2222
import namer.namer
23+
import namer.videohashes
2324
import namer.watchdog
2425
import namer.web
2526
from namer.configuration_utils import default_config
2627
from namer.models import db
27-
from namer.namer import calculate_phash
2828

2929
DESCRIPTION = (
3030
namer.namer.DESCRIPTION
@@ -33,9 +33,11 @@
3333
The first argument should be 'watchdog', 'rename', 'suggest', or 'help' to see this message, for more help on rename, call
3434
namer 'namer rename -h'
3535
36-
watchdog and help take no arguments (please see the config file example https://github.com/4c0d3r/namer/blob/main/namer.cfg)
36+
watchdog and help take no arguments (please see the config file example https://github.com/ThePornDatabase/namer/blob/main/namer/namer.cfg.default)
3737
3838
'suggest' takes a file name as input and will output a suggested file name.
39+
'url' print url to namer web ui.
40+
'hash' takes a file name as input and will output a hashes in json format.
3941
"""
4042
)
4143

@@ -79,9 +81,7 @@ def main():
7981
elif arg1 == 'url':
8082
print(f'http://{config.host}:{config.port}{config.web_root}')
8183
elif arg1 == 'hash':
82-
file = Path(arg_list[1])
83-
file_hash = calculate_phash(file, config)
84-
print(file_hash.to_dict())
84+
namer.videohashes.main(arg_list[1:])
8585
elif arg1 in ['-h', 'help', None]:
8686
print(DESCRIPTION)
8787

namer/command.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,8 @@ def _set_perms(target: Path, config: NamerConfig):
128128
file_perm: Optional[int] = int(str(config.set_file_permissions), 8) if config.set_file_permissions else None
129129
dir_perm: Optional[int] = int(str(config.set_dir_permissions), 8) if config.set_dir_permissions else None
130130

131-
if config.set_gid:
132-
os.lchown(target, uid=-1, gid=config.set_gid)
133-
134-
if config.set_uid:
135-
os.lchown(target, uid=config.set_uid, gid=-1)
131+
if config.set_gid or config.set_uid:
132+
os.lchown(target, uid=config.set_uid if config.set_uid else -1, gid=config.set_gid if config.set_gid else -1)
136133

137134
if target.is_dir() and dir_perm:
138135
target.chmod(dir_perm)

namer/namer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
File names are assumed to be of the form SITE.[YY]YY.MM.DD.String.of.performers.and.or.scene.name.<IGNORED_INFO>.[mp4|mkv].
3636
In the name, read the periods, ".", as any number of spaces " ", dashes "-", or periods ".".
3737
38-
Provided you have an access token to the porndb (free sign up) https://www.theporndb.net/, this program will
38+
Provided you have an access token to the porndb (free sign up) https://theporndb.net/, this program will
3939
attempt to match your file's name to search results from the porndb. Please note that the site must at least be
4040
a substring of the actual site name on the porndb, and the date must be within one day or the release date on the
4141
porndb for a match to be considered. If the log file flag is enabled then a <original file name minus ext>_namer.json.gz

namer/videohashes.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import argparse
2+
import sys
3+
from pathlib import Path
4+
from typing import List
5+
6+
from loguru import logger
7+
8+
from namer.configuration_utils import default_config
9+
from namer.namer import calculate_phash
10+
11+
12+
def main(args_list: List[str]):
13+
"""
14+
Command line interface to calculate hashes for a file.
15+
"""
16+
description = """
17+
Command line interface to calculate hashes for a file
18+
"""
19+
parser = argparse.ArgumentParser(description=description)
20+
parser.add_argument('-c', '--configfile', help='override location for a configuration file.', type=Path)
21+
parser.add_argument('-f', '--file', help='File we want to provide a match name for.', required=True, type=Path)
22+
parser.add_argument('-v', '--verbose', help='verbose, print logs', action='store_true')
23+
args = parser.parse_args(args=args_list)
24+
25+
config = default_config(args.configfile.absolute() if args.configfile else None)
26+
if args.verbose:
27+
level = 'DEBUG' if config.debug else 'INFO'
28+
logger.add(sys.stdout, format=config.console_format, level=level, diagnose=config.diagnose_errors)
29+
30+
file_hash = calculate_phash(args.file.absolute(), config)
31+
print(file_hash.to_dict())

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
"@popperjs/core": "^2.11.8",
1616
"bootstrap": "^5.3.3",
1717
"bootstrap-icons": "^1.11.3",
18-
"datatables.net": "^2.1.7",
19-
"datatables.net-bs5": "^2.1.7",
18+
"datatables.net": "^2.1.8",
19+
"datatables.net-bs5": "^2.1.8",
2020
"datatables.net-buttons": "^3.1.2",
2121
"datatables.net-buttons-bs5": "^3.1.2",
2222
"datatables.net-colreorder": "^2.0.4",
@@ -29,26 +29,26 @@
2929
"lodash": "^4.17.21"
3030
},
3131
"devDependencies": {
32-
"@babel/core": "^7.25.2",
33-
"@babel/preset-env": "^7.25.4",
32+
"@babel/core": "^7.25.8",
33+
"@babel/preset-env": "^7.25.8",
34+
"@eslint/eslintrc": "^3.1.0",
35+
"@eslint/js": "^9.12.0",
3436
"babel-loader": "^9.2.1",
3537
"copy-webpack-plugin": "^12.0.2",
3638
"css-loader": "^7.1.2",
3739
"css-minimizer-webpack-plugin": "^7.0.0",
38-
"eslint": "^9.11.1",
40+
"eslint": "^9.12.0",
3941
"eslint-config-standard": "^17.1.0",
40-
"eslint-plugin-import": "^2.30.0",
41-
"eslint-plugin-n": "^17.10.3",
42-
"eslint-plugin-promise": "^7.1.0",
4342
"file-loader": "^6.2.0",
43+
"globals": "^15.11.0",
4444
"html-minimizer-webpack-plugin": "^5.0.0",
4545
"husky": "^9.1.6",
4646
"lint-staged": "^15.2.10",
4747
"mini-css-extract-plugin": "^2.9.1",
4848
"postcss": "^8.4.47",
4949
"postcss-loader": "^8.1.1",
50-
"postcss-preset-env": "^10.0.5",
51-
"sass": "^1.79.4",
50+
"postcss-preset-env": "^10.0.7",
51+
"sass": "^1.80.0",
5252
"sass-loader": "^16.0.2",
5353
"terser-webpack-plugin": "^5.3.10",
5454
"webpack": "^5.95.0",

0 commit comments

Comments
 (0)