This commit is contained in:
Christoph Califice
2025-10-09 20:05:31 -03:00
parent ed22ef22bc
commit 0a5f88d75a
1442 changed files with 101562 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
import json
import os
import sys
# to import from a parent directory we need to add that directory to the system path
csd = os.path.dirname(os.path.realpath(__file__)) # get current script directory
parent = os.path.dirname(csd) # parent directory (should be the scrapers one)
sys.path.append(
parent
) # add parent dir to sys path so that we can import py_common from ther
try:
from py_common import graphql
from py_common import log
except ModuleNotFoundError:
print(
"You need to download the folder 'py_common' from the community repo! (CommunityScrapers/tree/master/scrapers/py_common)",
file=sys.stderr,
)
sys.exit()
REMOVE_EXT = False # remove file extension from title
def title_from_filename(js):
scene_id = js["id"]
scene_title = js["title"]
response = graphql.callGraphQL(
"""
query FilenameBySceneId($id: ID){
findScene(id: $id){
files {
path
}
}
}""",
{"id": scene_id},
)
assert response is not None
path = response["findScene"]["files"][0]["path"]
filename = os.path.basename(path)
if REMOVE_EXT:
filename = os.path.splitext(filename)[0]
if scene_title != filename:
log.info(
f"Scene {scene_id}: Title differs from filename: '{scene_title}' => '{filename}'"
)
return {"title": filename}
return {}
input = sys.stdin.read()
js = json.loads(input)
if sys.argv[1] == "title_from_filename":
ret = title_from_filename(js)
print(json.dumps(ret))

View File

@@ -0,0 +1,10 @@
name: Filename
# requires: py_common
sceneByFragment:
action: script
script:
- python3
- Filename.py
- title_from_filename
# Last Updated September 21, 2022

View File

@@ -0,0 +1,10 @@
id: Filename
name: Filename
metadata: {}
version: 3ba2809
date: "2023-12-14 01:07:15"
requires: []
source_repository: https://stashapp.github.io/CommunityScrapers/stable/index.yml
files:
- Filename.py
- Filename.yml