Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General improvements #519

Merged
merged 5 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need duplicate information ? I understand that we can ditch print, or convert it to debug but both print same data :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could get rid of prints, but prints do not appear in kodi.log unless set debug mode in Kodi, not plugin settings

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
56 changes: 43 additions & 13 deletions models/kodi_models.py
Original file line number Diff line number Diff line change
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