Skip to content

Commit

Permalink
Merge pull request #519 from bigretromike/general-improvements
Browse files Browse the repository at this point in the history
General improvements
  • Loading branch information
bigretromike authored Dec 28, 2023
2 parents dc3a715 + 71bf1cb commit ea1372c
Show file tree
Hide file tree
Showing 16 changed files with 300 additions and 54 deletions.
12 changes: 6 additions & 6 deletions api/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def call(self,
url = f"{self.proto}://{self.address}:{self.port}{url}?api-version={self.version}"
else:
url = f"{self.proto}://{self.address}:{self.port}{url}" # ?api-version={self.version}"
debug(f"api.call = {url}")

headers = {
'Accept': '*/*',
Expand All @@ -137,11 +136,9 @@ def call(self,
# Api Calls
req = None
if call_type == APIType.GET:
print(f"Api.GET === {url} -- -H {headers} -D {data}")
req = Request(url, data=data, headers=headers, method="GET")

elif call_type == APIType.POST:
print(f"Api.POST === {url} -- -H {headers} -D {data}")
if type(data) is dict:
data = json.dumps(data).encode("utf-8")
else:
Expand All @@ -150,21 +147,24 @@ def call(self,
req = Request(url, data=data, headers=headers, method="POST")

elif call_type == APIType.DELETE:
print(f"Api.DELETE === {url} -- -H {headers} -D {data}")
data = json.dumps(data).encode("utf-8")
req = Request(url, data=data, headers=headers, method="DELETE")

elif call_type == APIType.PATCH:
print(f"Api.PATCH === {url} -- -H {headers} -D {data}")
data = json.dumps(data).encode("utf-8")
req = Request(url, data=data, headers=headers, method="PATCH")

elif call_type == APIType.PUT:
print(f"Api.PUT == {url} -- -H {headers} -D {data}")
data = json.dumps(data).encode("utf-8")
req = Request(url, data=data, headers=headers, method="PUT")
else:
print(f"Unknown === {url}")
debug(f"Unknown === {url}")

print(f"Sending HTTP request: {req.method} {req.get_full_url()}\r\nHeaders: {req.headers}\r\nData: {req.data}")
debug(f"Sending HTTP request: {req.method} {req.get_full_url()}")
debug(f"\t\tHeaders: {req.headers}")
debug(f"\t\tData: {req.data}")

if req is not None:
if self.try_cache and req.method == 'GET':
Expand Down
4 changes: 2 additions & 2 deletions lib/naka_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@


class ThisType(IntEnum):
filters = 0
filter = 1
filters = 0 # "Seasons" or "Tags" has additional filters inside. Multinode filter
filter = 1 # "All", "Continue Watching", "Missing episodes", "Recently watched"... Single node filter
group = 2
series = 3
# episodes type
Expand Down
62 changes: 46 additions & 16 deletions models/kodi_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_listitem_from_serie(x: api2models.Serie, forced_title: str = None) -> Li
if x.art is not None:
set_art(li, x.art)
set_folder(li, True)
set_unieque_ids(li, x.aid)
set_unique_ids(li, x.aid)
rating = x.rating if x.rating is not None else 0
votes = int(x.votes) if x.votes is not None else 0
set_rating(li, rate_type='anidb', rate_value=float(rating), votes=int(votes), default=True)
Expand Down Expand Up @@ -162,7 +162,7 @@ def get_listitem_from_episode(x: api2models.Episode, series_title: str = '', cas
if x.art is not None:
set_art(li, spoiler_control_images(x.art, hide_spoiler))
set_folder(li, False)
set_unieque_ids(li, x.aid)
set_unique_ids(li, x.aid)
# set_rating(li, rate_type='anidb', rate_value=float(x.rating), votes=int(x.votes), default=True)
#add_season(li, season_name='__season__', season_number=1)
set_info_for_episode(li, x, series_title)
Expand Down Expand Up @@ -501,7 +501,7 @@ def set_folder(li: ListItem, is_folder: bool = True):
li.setIsFolder(is_folder)


def set_unieque_ids(li: ListItem, anidb_id=None):
def set_unique_ids(li: ListItem, anidb_id=None):
if anidb_id is not None:
li.setUniqueIDs({'anidb': anidb_id})

Expand Down Expand Up @@ -851,24 +851,34 @@ def main_menu_items() -> List[ListItem]:
# 'Unsort': 5, 'Settings' (both): 7, 'Shoko Menu': 8, 'Search': 9, Experiment: 99}

items: List[ListItem] = []
img = plugin_img_path + '/%s/%s'
# img = plugin_img_path + '/%s/%s'

if plugin_addon.getSettingBool('show_favorites'):
name = color(plugin_addon.getLocalizedString(30211), plugin_addon.getSetting('color_favorites'))
if plugin_addon.getSettingBool('bold_favorites'):
name = bold(name)
item = ListItem(name, path='plugin://plugin.video.nakamori/favorites')
img_name = 'airing.png'
item.setArt({'fanart': img % ('backgrounds', img_name), 'banners': img % ('banners', img_name), 'poster': img % ('icons', img_name)})
# img_name = 'airing.png'
item.setArt({
'fanart': f'{plugin_img_path}/backgrounds/airing.png',
'banners': f'{plugin_img_path}/banners/airing.png',
'poster': f'{plugin_img_path}/icons/airing.png',
'icon': f'{plugin_img_path}/icons/airing.png'
})
items.append(item)

if plugin_addon.getSettingBool('show_recent2'):
name = color(plugin_addon.getLocalizedString(30170), plugin_addon.getSetting('color_recent2'))
if plugin_addon.getSettingBool('bold_recent2'):
name = bold(name)
item = ListItem(name, path='plugin://plugin.video.nakamori/recent')
img_name = '/airing.png'
item.setArt({'fanart': img % ('backgrounds', img_name), 'banners': img % ('banners', img_name), 'poster': img % ('icons', img_name)})
# img_name = 'airing.png'
item.setArt({
'fanart': f'{plugin_img_path}/backgrounds/airing.png',
'banners': f'{plugin_img_path}/banners/airing.png',
'poster': f'{plugin_img_path}/icons/airing.png',
'icon': f'{plugin_img_path}/icons/airing.png'
})
items.append(item)

# TODO airing today
Expand All @@ -888,35 +898,55 @@ def main_menu_items() -> List[ListItem]:
# isfolter
else:
item = ListItem(name, path='plugin://plugin.video.nakamori/calendar')
img_name = 'calendar.png'
item.setArt({'fanart': img % ('backgrounds', img_name), 'banners': img % ('banners', img_name), 'poster': img % ('icons', img_name)})
# img_name = 'calendar.png'
item.setArt({
'fanart': f'{plugin_img_path}/backgrounds/calendar.png',
'banners': f'{plugin_img_path}/banners/calendar.png',
'poster': f'{plugin_img_path}/icons/calendar.png',
'icon': f'{plugin_img_path}/icons/calendar.png'
})
items.append(item)

if plugin_addon.getSettingBool('show_settings'):
name = color(plugin_addon.getLocalizedString(30107), plugin_addon.getSetting('color_settings'))
if plugin_addon.getSettingBool('bold_settings'):
name = bold(name)
item = ListItem(name, path='plugin://plugin.video.nakamori/settings')
img_name = 'settings.png'
item.setArt({'fanart': img % ('backgrounds', img_name), 'banners': img % ('banners', img_name), 'poster': img % ('icons', img_name)})
# img_name = 'settings.png'
item.setArt({
'fanart': f'{plugin_img_path}/backgrounds/settings.png',
'banners': f'{plugin_img_path}/banners/settings.png',
'poster': f'{plugin_img_path}/icons/settings.png',
'icon': f'{plugin_img_path}/icons/settings.png'
})
items.append(item)

if plugin_addon.getSettingBool('show_shoko'):
name = color(plugin_addon.getLocalizedString(30115), plugin_addon.getSetting('color_shoko'))
if plugin_addon.getSettingBool('bold_shoko'):
name = bold(name)
item = ListItem(name, path='plugin://plugin.video.nakamori/shoko')
img_name = 'settings.png'
item.setArt({'fanart': img % ('backgrounds', img_name), 'banners': img % ('banners', img_name), 'poster': img % ('icons', img_name)})
# img_name = 'settings.png'
item.setArt({
'fanart': f'{plugin_img_path}/backgrounds/settings.png',
'banners': f'{plugin_img_path}/banners/settings.png',
'poster': f'{plugin_img_path}/icons/settings.png',
'icon': f'{plugin_img_path}/icons/settings.png'
})
items.append(item)

if plugin_addon.getSettingBool('show_search'):
name = color(plugin_addon.getLocalizedString(30221), plugin_addon.getSetting('color_search'))
if plugin_addon.getSettingBool('bold_search'):
name = bold(name)
item = ListItem(name, path='plugin://plugin.video.nakamori/search')
img_name = 'search.png'
item.setArt({'fanart': img % ('backgrounds', img_name), 'banners': img % ('banners', img_name), 'poster': img % ('icons', img_name)})
# img_name = 'search.png'
item.setArt({
'fanart': f'{plugin_img_path}/backgrounds/search.png',
'banners': f'{plugin_img_path}/banners/search.png',
'poster': f'{plugin_img_path}/icons/search.png',
'icon': f'{plugin_img_path}/icons/search.png'
})
items.append(item)

return items
Expand Down
Loading

0 comments on commit ea1372c

Please sign in to comment.