This commit is contained in:
VineFeeder
2026-06-16 11:09:54 +01:00
parent 8599327199
commit ef2de814a1
@@ -60,7 +60,8 @@ class TPTV(Service):
Then use a search term in preference to a url. Then use a search term in preference to a url.
Dealing with COLLECTION: Dealing with COLLECTION:
In envied, any url with COLLECTION in capitals will attempt to list the whole. In envied, any url with COLLECTION in capitals will attempt to list the whole collection.
In vinefeeder, COLLECTION is ignored and the descriptive in the url is used as a search term. In vinefeeder, COLLECTION is ignored and the descriptive in the url is used as a search term.
eg https://tptvencore.co.uk/details/COLLECTION/collection/01KRKTC8WZ7X584YPA5NBFYJSS/the-danziger-collection eg https://tptvencore.co.uk/details/COLLECTION/collection/01KRKTC8WZ7X584YPA5NBFYJSS/the-danziger-collection
will be treated as a search for "the danziger collection" in vinefeeder, but will attempt to list the whole collection in envied. will be treated as a search for "the danziger collection" in vinefeeder, but will attempt to list the whole collection in envied.
@@ -192,151 +193,6 @@ class TPTV(Service):
print(f"Searching not implemented in Envied for TPTVencore. Please use VineFeeder instead.") print(f"Searching not implemented in Envied for TPTVencore. Please use VineFeeder instead.")
return None return None
'''def get_titles(self) -> Union[Movies, Series]:
data = self.get_data(self.title)
#ids = ",".join(data)
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:138.0) Gecko/20100101 Firefox/138.0',
'Accept': '*/*',
'Accept-Language': 'en-GB,en;q=0.5',
'Referer': 'https://tptvencore.co.uk/',
'tenant': 'encore',
'Origin': 'https://tptvencore.co.uk',
'DNT': '1',
'Connection': 'keep-alive',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'Priority': 'u=4',
}
session_id = self.session.headers['session']
headers['session'] = session_id
se_pattern = re.compile(
r"\(\s*S\s*(?P<series>\d+)\s*,\s*EP\s*(?P<episode>\d+)\s*\)",
re.IGNORECASE
)
if len(data) > 1:
# multiple items, treat as a series
episodes = []
for item_id in data:
print(len(str(item_id)))
if len(str(item_id)) > 20: # Skip item IDs that too long
continue
# Skip this item if it too long to be valid.
try: # two possible endpoints for item data, try both
response = self.session.get(f'https://tptvencore.co.uk/api/core/catalog/item/{item_id}?locale=en', headers=headers)
if response.status_code != 200:
raise Exception()
except:
try:
response = self.session.get(f'https://tptvencore.co.uk/api/core/catalog/collection/{item_id}?locale=en', headers=headers)
if response.status_code != 200:
raise Exception()
except:
continue # next item if both endpoints fail, thus ignore.
mydata = json.loads(response.text)
f = open("tptv_debug.json", "w")
f.write(json.dumps(mydata, indent=4))
f.close()
console.print_json(data=mydata)
exit(0)
item = mydata['data']
title = mydata.get("title")
# some series exist with season/episode info,(most do not),
# so we try to extract it from the title if possible
match = se_pattern.search(title)
if match:
season = int(match.group("series"))
number = int(match.group("episode"))
else:
season = 0
number = 0
episodes.append(
Episode(
id_=item["id"],
service=self.__class__,
title=title,
season=season or 0,
number=number or 0,
name="",
language="en",
data=item,
)
)
#return Series(episodes)
else:
try:
response = self.session.get(f'https://tptvencore.co.uk/api/core/catalog/collection/{data[0]}?page=1&pageSize=20&locale=en', headers=headers)
if response.status_code != 200:
raise ConnectionRefusedError()
except:
try:
response = self.session.get(f'https://tptvencore.co.uk/api/core/catalog/item/{data[0]}?locale=en', headers=headers)
except:
raise ConnectionError("Failed to retrieve title data")
mydata = json.loads(response.text)
titles = mydata['data']
episodes = []
season = 0
number = 0
if (len(mydata)) > 1:
for item in titles:
title = item["title"]
# some series exist with season/episode info,(most do not),
# so we try to extract it from the title if possible
match = se_pattern.search(title)
if match:
season = int(match.group("series"))
number = int(match.group("episode"))
episodes.append(
Episode(
id_=item["id"],
service=self.__class__,
title=title,
season=season or 0,
number=number or 0,
name="",
language="en",
data=item,
)
)
else:
# single item, treat as a movie
item = titles
title = item["title"]
# some series exist with season/episode info,(most do not),
# so we try to extract it from the title if possible
match = se_pattern.search(title)
if match:
season = int(match.group("series"))
number = int(match.group("episode"))
episodes.append(
Episode(
id_=item["id"],
service=self.__class__,
title=item["title"],
season=season or 0,
number=number or 0,
name="",
language="en",
data=item,
)
)
return Series(episodes)'''
def get_titles(self) -> Union[Movies, Series]: def get_titles(self) -> Union[Movies, Series]:
data = self.get_data(self.title) data = self.get_data(self.title)