44import sys
55import os
66import xbmc
7+ import xbmcgui
78import xbmcaddon
9+ import urllib .parse
810from bs4 import BeautifulSoup
911
1012#
1315ADDON = "plugin.video.worldstarhiphop"
1416SETTINGS = xbmcaddon .Addon ()
1517LANGUAGE = SETTINGS .getLocalizedString
16- BASEURLWSHH = "https://worldstarhiphop.com"
17- BASEURLWS = "https://worldstar.com"
18+ BASE_URL_WSHH = "https://worldstarhiphop.com"
19+ INITIAL_API_VIDEO_URL = "https://api-mobile.worldstar.com/video/feed?daysSize=2&heroVideosSize=3&clean=false&pageCursor="
20+ INITIAL_API_SEARCH_URL = "https://api-mobile.worldstar.com/search/suggestion?searchTerm=<search_string>&pageSize=40&filter=newest&clean=false"
1821IMAGES_PATH = os .path .join (xbmcaddon .Addon ().getAddonInfo ('path' ), 'resources' )
1922HEADERS = {'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36' }
20- DATE = "2022-04-21 "
21- VERSION = "1.0.14 "
23+ DATE = "2025-07-01 "
24+ VERSION = "1.0.16 "
2225
2326
2427if sys .version_info [0 ] > 2 :
@@ -48,4 +51,88 @@ def log(name_object, object):
4851
4952def getSoup (html , default_parser = "html5lib" ):
5053 soup = BeautifulSoup (html , default_parser )
51- return soup
54+ return soup
55+
56+
57+ def create_video_list_item (video_data , addon_name , images_path , log ):
58+ """
59+ Creates and configures an xbmcgui.ListItem for a video.
60+
61+ Args:
62+ video_data (dict): Dictionary containing video information.
63+ addon_name (str): The name of the addon.
64+ images_path (str): Path to the addon's images.
65+ log (function): The logging function to use.
66+
67+ Returns:
68+ xbmcgui.ListItem: The configured list item, or None if data is malformed.
69+ """
70+ try :
71+ title = video_data .get ('title' , '' )
72+ title_highlight = video_data .get ('titleHighlight' , '' )
73+ description = video_data .get ('description' , '' )
74+ duration = video_data .get ('duration' , 0 )
75+ thumbnail_url = video_data .get ('imageUrl' , '' )
76+ except KeyError as e :
77+ log ("ERROR" , f"Missing key in video data: { e } " )
78+ return None # Return None if data is malformed
79+
80+ log ("title" , title )
81+ log ("title_highlight" , title_highlight )
82+ log ("description" , description )
83+ log ("duration" , duration )
84+ log ("thumbnail_url" , thumbnail_url )
85+
86+ if title_highlight == "" :
87+ plot = description
88+ else :
89+ plot = title_highlight
90+
91+ log ("plot" , plot )
92+
93+ list_item = xbmcgui .ListItem (title )
94+ list_item .setInfo ("video" , {
95+ "title" : title ,
96+ "studio" : addon_name ,
97+ "plot" : plot ,
98+ "duration" : duration
99+ })
100+ list_item .setArt ({
101+ 'thumb' : thumbnail_url ,
102+ 'icon' : thumbnail_url ,
103+ 'fanart' : os .path .join (images_path , 'fanart-blur.jpg' )
104+ })
105+ list_item .setProperty ('IsPlayable' , 'true' )
106+
107+ # Add refresh option to context menu
108+ list_item .addContextMenuItems ([('Refresh' , 'Container.Refresh' )])
109+
110+ return list_item
111+
112+ def add_video_to_listing (video_data , plugin_url , listing , addon_name , images_path , log ):
113+ """
114+ Processes a video dictionary, creates a list item, and appends it to the listing.
115+
116+ Args:
117+ video_data (dict): Dictionary containing video information.
118+ plugin_url (str): The base plugin URL.
119+ listing (list): The list to append the new list item to.
120+ addon_name (str): The name of the addon.
121+ images_path (str): Path to the addon's images.
122+ log (function): The logging function to use.
123+ """
124+ list_item = create_video_list_item (video_data , addon_name , images_path , log )
125+ # Skip if list item creation failed
126+ if list_item is None :
127+ return
128+
129+ video_url = video_data .get ('videoUrl' , '' )
130+
131+ log ("video_url" , video_url )
132+
133+ parameters = {"action" : "play" , "video_page_url" : video_url }
134+ url = f"{ plugin_url } ?{ urllib .parse .urlencode (parameters )} "
135+ is_folder = False
136+
137+ # Add our item to the listing as a 3-element tuple.
138+ listing .append ((url , list_item , is_folder ))
0 commit comments