This commit is contained in:
VineFeeder
2026-04-26 13:27:46 +01:00
parent 070f809da3
commit 9e3d6dea08
8 changed files with 776 additions and 309 deletions
@@ -1,4 +1,5 @@
import json
from typing import List, Tuple
from scrapy import Selector
catppuccin_mocha = {
@@ -210,6 +211,31 @@ def extract_with_xpath(html, pattern, delete_pattern=None, index=0):
return None
def extract_aria_label_and_href(html: str) -> List[Tuple[str, str]]:
"""
Extract (aria-label, href) pairs from <a> tags in the supplied HTML.
Args:
html: Full HTML document as a string.
Returns:
A list of tuples in the form:
[
("The Boondock Saints (1999)", "/en-GB/movie/the-boondock-saints"),
...
]
"""
selector = Selector(text=html)
results = []
for a in selector.css("a[aria-label][href]"):
aria_label = a.attrib.get("aria-label", "").strip()
href = a.attrib.get("href", "").strip()
results.append((aria_label, href))
return results
def rinse(string):
"""Remove non-printable characters from a string."""
illegals = "*'%$!(),;"
@@ -274,16 +274,19 @@ class PlexLoader(BaseLoader):
None
"""
category = browse_url.split('/')[-1]
browse_url = f"https://luma.plex.tv/api/screen/on-demand/category/{category}"
browse_url = f"https://luma.plex.tv/api/v2/screen/on-demand/category/{category}"
beaupylist = [] # hold beaupy data for display and programme selection
headers = {
"Accept": "application/json",
"Origin": "https://plex.tv",
"X-Plex-Product": "Plex Mediaverse",
"X-Plex-Version": "1.0",
"X-Plex-Client-Identifier": str(uuid.uuid4()),
}
try:
myjson = self.parse_data(self.get_data(browse_url))
myjson = self.parse_data(self.get_data(browse_url, headers=headers))
res = jmespath.search(
"""
ui.list.content[].{
@@ -3,16 +3,16 @@ service_name: PLEX
options: -l en
media_dict:
action: https://watch.plex.tv/on-demand/category/action
animation: https://watch.plex.tv/on-demand/category/animation
comedy: https://watch.plex.tv/on-demand/category/comedy
crime: https://watch.plex.tv/on-demand/category/crime
documentary: https://watch.plex.tv/on-demand/category/documentary
drama: https://watch.plex.tv/on-demand/category/drama
en epsaniol: https://watch.plex.tv/on-demand/category/en-espanol
horror: https://watch.plex.tv/on-demand/category/horror
music: https://watch.plex.tv/on-demand/category/music
romance: https://watch.plex.tv/on-demand/category/romance
sci-fi: https://watch.plex.tv/on-demand/category/sci-fi
thriller: https://watch.plex.tv/on-demand/category/thriller
western: https://watch.plex.tv/on-demand/category/western
action: https://watch.plex.tv/en-GB/on-demand/category/action
animation: https://watch.plex.tv/en-GB/on-demand/category/animation
comedy: https://watch.plex.tv/en-GB/on-demand/category/comedy
crime: https://watch.plex.tv/en-GB/on-demand/category/crime
documentary: https://watch.plex.tv/en-GB/on-demand/category/documentary
drama: https://watch.plex.tv/en-GB/on-demand/category/drama
en epsaniol: https://watch.plex.tv/en-GB/on-demand/category/en-espanol
horror: https://watch.plex.tv/en-GB/on-demand/category/horror
music: https://watch.plex.tv/en-GB/on-demand/category/music
romance: https://watch.plex.tv/en-GB/on-demand/category/romance
sci-fi: https://watch.plex.tv/en-GB/on-demand/category/sci-fi
thriller: https://watch.plex.tv/en-GB/on-demand/category/thriller
western: https://watch.plex.tv/en-GB/on-demand/category/western