Skip to content

Commit 1fddc53

Browse files
authored
Merge pull request #21 from l34240013/main
Update group scraper
2 parents 30dab06 + 71cef2e commit 1fddc53

6 files changed

Lines changed: 28 additions & 43 deletions

File tree

plugins/Stash_Group_ADVE_Movie_Plugin/README.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ which you're still missing.
1212
|---|---|
1313
| Stash v0.25+ | Plugin API + patch system |
1414
| Python 3.10+ | Backend scraper |
15-
| `requests`, `beautifulsoup4` | `pip install -r requirements.txt` |
15+
| `requests`, `beautifulsoup4`, `stashapp-tools` | `pip install -r requirements.txt` |
1616

1717
---
1818

@@ -39,16 +39,12 @@ text editor and fill in the three values:
3939

4040
```json
4141
{
42-
"stash_url": "http://localhost:9999",
43-
"stash_api_key": "",
4442
"adve_session_cookie": "ageConfirmed=true; defaults={}; etoken=PASTE_YOUR_ETOKEN_HERE"
4543
}
4644
```
4745

4846
| Key | Description |
4947
|---|---|
50-
| `stash_url` | URL of your Stash instance. Change if you use a custom port or remote host. |
51-
| `stash_api_key` | API key for your Stash instance. Leave blank if authentication is not enabled. |
5248
| `adve_session_cookie` | Your AdultDVDEmpire session cookie string. See instructions below. |
5349

5450
### How to get your AdultDVDEmpire session cookie
@@ -149,7 +145,7 @@ Each ADVE scene is matched to a Stash scene using these strategies in order:
149145
Stash_Group_ADVE_Movie_Plugin/
150146
├── Stash_Group_ADVE_Movie_Plugin.yml ← Plugin manifest
151147
├── checker.py ← Backend: scraper + GraphQL + matching
152-
├── config.json ← Your settings (URL, API key, cookie)
148+
├── config.json ← Your settings (AdultDVDEmpire session cookie)
153149
├── requirements.txt ← Python dependencies
154150
├── panel.js ← Frontend UI injected into Group pages
155151
├── results/ ← Auto-created; persisted result JSON files

plugins/Stash_Group_ADVE_Movie_Plugin/Stash_Group_ADVE_Movie_Plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: "Stash Group ADVE Movie Checker"
22
description: "Compares scenes in a Stash Group against AdultDVDEmpire. Requires an ADVE URL in the Group's URL list."
3-
version: "0.8.0"
3+
version: "1.0.0"
44

55
ui:
66
javascript:

plugins/Stash_Group_ADVE_Movie_Plugin/checker.py

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
import hashlib
1919
import requests
2020
from typing import Optional
21+
22+
from stashapi.stashapp import StashInterface
2123
try:
2224
from bs4 import BeautifulSoup
2325
except ImportError:
@@ -84,8 +86,6 @@ def progress(pct: float):
8486
except Exception as _e:
8587
log.warning(f"Could not read config.json: {_e}")
8688

87-
STASH_URL = os.getenv("STASH_URL") or _config.get("stash_url", "http://localhost:9999")
88-
STASH_API_KEY = os.getenv("STASH_API_KEY") or _config.get("stash_api_key", "")
8989
ADVE_SESSION_COOKIE = os.getenv("ADVE_SESSION_COOKIE") or _config.get("adve_session_cookie", "")
9090

9191
HEADERS = {
@@ -104,21 +104,7 @@ def progress(pct: float):
104104
# STASH GRAPHQL
105105
# ─────────────────────────────────────────────
106106

107-
def stash_gql(query: str, variables: dict = None) -> dict:
108-
headers = {"Content-Type": "application/json"}
109-
if STASH_API_KEY:
110-
headers["ApiKey"] = STASH_API_KEY
111-
resp = requests.post(
112-
f"{STASH_URL}/graphql",
113-
json={"query": query, "variables": variables or {}},
114-
headers=headers,
115-
timeout=15,
116-
)
117-
resp.raise_for_status()
118-
return resp.json().get("data", {})
119-
120-
121-
def get_group(group_id: str) -> dict:
107+
def get_group(stash: StashInterface, group_id: str) -> dict:
122108
query = """
123109
query FindGroup($id: ID!) {
124110
findGroup(id: $id) {
@@ -134,10 +120,11 @@ def get_group(group_id: str) -> dict:
134120
}
135121
}
136122
"""
137-
return stash_gql(query, {"id": group_id}).get("findGroup")
123+
result = stash.call_GQL(query, {"id": group_id})
124+
return result.get("findGroup")
138125

139126

140-
def get_all_groups() -> list:
127+
def get_all_groups(stash: StashInterface) -> list:
141128
query = """
142129
query AllGroups($filter: FindFilterType, $group_filter: GroupFilterType) {
143130
findGroups(filter: $filter, group_filter: $group_filter) {
@@ -147,15 +134,16 @@ def get_all_groups() -> list:
147134
"""
148135
# per_page: -1 returns all records; group_filter restricts to groups
149136
# whose URL list contains an adultdvdempire.com URL.
150-
return stash_gql(query, {
137+
result = stash.call_GQL(query, {
151138
"filter": {"per_page": -1},
152139
"group_filter": {
153140
"url": {
154141
"value": "adultdvdempire.com",
155142
"modifier": "INCLUDES",
156143
}
157144
},
158-
}).get("findGroups", {}).get("groups", [])
145+
})
146+
return result.get("findGroups", {}).get("groups", [])
159147

160148

161149
# ─────────────────────────────────────────────
@@ -418,8 +406,8 @@ def match_scene(adve_scene: dict, stash_scenes: list) -> Optional[dict]:
418406
return None
419407

420408

421-
def build_comparison(group_id: str) -> dict:
422-
group = get_group(group_id)
409+
def build_comparison(stash: StashInterface, group_id: str) -> dict:
410+
group = get_group(stash, group_id)
423411
if not group:
424412
return {"error": f"Group {group_id} not found in Stash."}
425413

@@ -473,32 +461,31 @@ def main():
473461
sys.exit(1)
474462

475463
def _run():
476-
raw = sys.stdin.read().strip()
477-
try:
478-
plugin_input = json.loads(raw) if raw else {}
479-
except json.JSONDecodeError:
480-
plugin_input = {}
464+
json_input = json.loads(sys.stdin.read())
481465

482466
if ADVE_SESSION_COOKIE:
483467
log.info("Session cookie loaded from config.json")
484468
else:
485469
log.warning("No session cookie found in config.json or environment")
486470

487-
args = plugin_input.get("args", {})
471+
server_connection = json_input["server_connection"]
472+
stash = StashInterface(server_connection)
473+
474+
args = json_input.get("args", {})
488475
mode = args.get("mode", "check_group")
489476

490477
if mode == "check_group":
491478
group_id = args.get("group_id")
492479
if not group_id:
493480
result = {"error": "group_id is required"}
494481
else:
495-
result = build_comparison(group_id)
482+
result = build_comparison(stash, group_id)
496483
# Write to result file so JS can poll for it
497484
write_result(group_id, result)
498485
print(json.dumps(result))
499486

500487
elif mode == "scrape_all":
501-
groups = get_all_groups()
488+
groups = get_all_groups(stash)
502489
total = len(groups)
503490
summary = []
504491
log.info(f"Scraping {total} groups with ADVE URLs...")
@@ -508,7 +495,7 @@ def _run():
508495
for idx, g in enumerate(groups, start=1):
509496
if find_adve_url(g.get("urls", [])):
510497
log.info(f"[{idx}/{total}] {g['name']}")
511-
result = build_comparison(g["id"])
498+
result = build_comparison(stash, g["id"])
512499
write_result(g["id"], result)
513500
summary.append({
514501
"group_id": g["id"],
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
{
2-
"stash_url": "http://localhost:9999",
3-
"stash_api_key": "",
42
"adve_session_cookie": "ageConfirmed=true; defaults={}; etoken=PASTE_YOUR_ETOKEN_HERE"
53
}

plugins/Stash_Group_ADVE_Movie_Plugin/manifest

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ id: Stash_Group_ADVE_Movie_Plugin
22
name: Stash Group ADVE Movie Plugin
33
metadata:
44
description: Compares scenes in a Stash Group against AdultDVDEmpire. Requires an ADVE URL in the Group's URL list.
5-
version: 0.8.0
6-
date: "2026-03-22 00:42:09"
5+
version: 1.0.0
6+
date: "2026-04-03 12:22:00"
77
requires: []
88
source_repository: https://lurking987.github.io/stash-plugins/main/index.yml
99
files:
@@ -12,3 +12,4 @@ files:
1212
- README.md
1313
- panel.js
1414
- checker.py
15+
- requirements.txt
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
stashapp-tools
2+
requests
3+
beautifulsoup4

0 commit comments

Comments
 (0)