Skip to content

Commit 5f8e1d0

Browse files
committed
Fixed fuzzy search, search for each category added, removed broken random search
1 parent 94cc17d commit 5f8e1d0

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

addon.py

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
API_ENDPOINT_ALBUMS = "https://stripchat.com/api/front/users/username/{0}/albums"
4646
API_ENDPOINT_ALBUM = "https://stripchat.com/api/front/users/username/{0}/albums/{1}/photos"
4747
API_ENDPOINT_VIDEOS = "https://stripchat.com/api/front/users/username/{0}/videos"
48-
API_ENDPOINT_SEARCH = "https://stripchat.com/api/front/v4/models/search/group/username?query={0}&limit=99"
49-
# differentiated API_ENDPOINT_SEARCH = "https://stripchat.com/api/front/v4/models/search/group/all?query={0}&limit=100"
48+
API_ENDPOINT_SEARCH = "https://stripchat.com/api/front/v4/models/search/group/username?query={0}&primaryTag={1}&limit=99"
49+
5050
SNAPSHOT_IMAGE = "https://img.strpst.com/{0}/thumbs/{1}/{2}_webp"
5151

5252
# User agent(s)
@@ -88,12 +88,12 @@
8888
('Categories - Guys', "sitecat=cats-m", "Show guys cams only."),
8989
('Categories - Trans', "sitecat=cats-t", "Show trans cams only."),
9090
("Favourites", "favourites", "Favourites list. Online status will be checked on opening the list."),
91-
("Search", "search", "Search for an exact username.\nA little more info about than with fuzzy search."),
92-
("Fuzzy search", "fuzzy", "List cams containing searchterm in username."),
93-
("Random 50", "randomx", "Random 50 live models (girls)"),
91+
("Search", "fuzzy/girls", "Search for cams. Girls only. Search for other genres with search in each category."),
92+
("Search Exact", "search", "Search for an exact username.\nA little more info about cam than normal search."),
9493
("Tools", "sitecat=tools", "Some tools for cleanup and favourites.")
9594
)
96-
SITE_CATS_F = (("All", "category/girls", ""),
95+
SITE_CATS_F = (("Search", "fuzzy/girls", "Search for cams in girls category"),
96+
("All", "category/girls", ""),
9797
("Recommended", "category/girls/recommended", ""),
9898
("VR cams", "category/girls/autoTagVr", ""),
9999
("New cams", "category/girls/autoTagNew", ""),
@@ -108,11 +108,14 @@
108108
("Indian", "category/girls/ethnicityIndian", ""),
109109
("Latina", "category/girls/ethnicityLatino", ""),
110110
("White", "category/girls/ethnicityWhite", ""))
111-
SITE_CATS_M = (('All', "category/men", ""),
111+
SITE_CATS_M = (("Search", "fuzzy/men", "Search for cams in men category"),
112+
('All', "category/men", ""),
112113
("New cams", "category/men/autoTagNew", ""))
113-
SITE_CATS_C = (('All', "category/couples", ""),
114+
SITE_CATS_C = (("Search", "fuzzy/couples", "Search for cams in couples category"),
115+
('All', "category/couples", ""),
114116
("New cams", "category/couples/autoTagNew", ""))
115-
SITE_CATS_T = (('All', "category/trans", ""),
117+
SITE_CATS_T = (("Search", "fuzzy/trans", "Search for cams in trans category"),
118+
('All', "category/trans", ""),
116119
("New cams", "category/trans/autoTagNew", ""))
117120
SITE_TOOLS = (("Backup Favourites", "tool=fav-backup", "Backup favourites (Set backup location in settings first). \nExisting favourites file will be overwritten without warning."),
118121
("Restore Favourites", "tool=fav-restore", "Restore your favourites from backup location."),
@@ -135,16 +138,16 @@ def evaluate_request():
135138
get_menu("main")
136139
return
137140

138-
param = sys.argv[2]
141+
# URL decode the parameter
142+
param = urllib.parse.unquote(sys.argv[2])
139143

140144
# Map parameters to functions
141145
param_map = {
142146
"sitecat=": get_menu,
143147
"favourites": get_favourites,
144148
"search": search_actor,
145149
"getProfile": get_profile_data,
146-
"fuzzy": search_actor2,
147-
"randomx": get_cams_from_json,
150+
"fuzzy/": search_actor2,
148151
"tool=": handle_tool,
149152
"category": get_cams_by_category,
150153
"playactor=": play_actor,
@@ -160,6 +163,9 @@ def evaluate_request():
160163
# Find matching parameter and call corresponding function
161164
for key, func in param_map.items():
162165
if key in param:
166+
if key == "fuzzy/":
167+
func(param.split("fuzzy/")[1].split("?")[0])
168+
return
163169
if key == "sitecat=":
164170
func(re.findall(r'sitecat=(.*)', param)[0])
165171
elif key == "getProfile":
@@ -369,7 +375,7 @@ def get_favourites():
369375
xbmcplugin.addDirectoryItems(PLUGIN_ID, items)
370376
xbmcplugin.endOfDirectory(PLUGIN_ID)
371377

372-
378+
# Old random 50 function
373379
def get_cams_from_json():
374380
"""List available cams by category"""
375381
data = get_site_page_full('https://go.stripchat.com/api/models?limit=50')
@@ -868,7 +874,7 @@ def get_site_page_full(page):
868874
def search_actor():
869875
"""Search for actor/username and list item if username exists"""
870876

871-
s = xbmcgui.Dialog().input("Search username")
877+
s = xbmcgui.Dialog().input("Search for exact username")
872878
if s == '':
873879
xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False)
874880
else:
@@ -969,16 +975,17 @@ def search_actor():
969975

970976

971977

972-
def search_actor2():
973-
"""Fuzzy Search for actor/username and list item if username is online"""
978+
def search_actor2(primaryTag=None):
979+
"""Fuzzy search for cams and list items if username exists"""
974980

975-
s = xbmcgui.Dialog().input("Fuzzy search username")
981+
s = xbmcgui.Dialog().input("Search for username")
976982
if s == '':
977983
xbmcplugin.endOfDirectory(int(sys.argv[1]), succeeded=False)
978984
return
979985

980-
url = API_ENDPOINT_SEARCH.format(s)
981-
xbmc.log("URL: " + url,1)
986+
url = API_ENDPOINT_SEARCH.format(s, primaryTag if primaryTag else "girls")
987+
xbmc.log(f"Search URL: {url}", 1)
988+
982989
try:
983990
data = get_site_page_full(url)
984991
cams = json.loads(data)

0 commit comments

Comments
 (0)