Skip to content

Commit

Permalink
unify actions in route
Browse files Browse the repository at this point in the history
  • Loading branch information
pablouser1 committed Dec 29, 2023
1 parent 6ef6f11 commit c9878d0
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
4 changes: 3 additions & 1 deletion resources/lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@
SEASONS='seasons',
EPISODES='episodes',
WATCHLATER='watchlater',
PLAYER='player'
PLAYER='player',
LOGOUT='logout',
PROFILE='profile'
)
14 changes: 7 additions & 7 deletions resources/lib/helpers/Render.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def static(items: list)-> list:
info = {
"title": item["title"]
}
url = '{0}?menu={1}'.format(_URL, item["id"])
url = '{0}?route={1}'.format(_URL, item["id"])
list_item.setInfo('video', info)
listing.append((url, list_item, True))

Expand All @@ -30,23 +30,23 @@ def videos(items: list)-> list:
"""
listing = []
for item in items:
url = '{0}?menu=player&id={1}'.format(_URL, item["id"])
url = '{0}?route=player&id={1}'.format(_URL, item["id"])
list_item = ListItemExtra.video(url, item)
listing.append((url, list_item, False))
return listing

@staticmethod
def folders(items: list, menu: str = '')-> list:
def folders(items: list, route: str = '')-> list:
"""
Render folders fetched from Filmin API
"""
listing = []
for item in items:
if not menu:
if not route:
if item['type'] == Types.folders[0]:
menu = 'seasons'
url = '{0}?menu={1}&id={2}'.format(_URL, menu, item["id"])
if menu == 'episodes':
route = 'seasons'
url = '{0}?route={1}&id={2}'.format(_URL, route, item["id"])
if route == 'episodes':
# Add show id to URL
url += '&item_id={0}'.format(_PARAMS['id'])
list_item = ListItemExtra.folder(url, item)
Expand Down
23 changes: 12 additions & 11 deletions resources/lib/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ def _player(item_id: int):
play = Play(item_id)
play.start()

@dispatcher.register(ROUTES.LOGOUT)
def _logout():
from .session import startLogout
startLogout()

@dispatcher.register(ROUTES.PROFILE)
def _profile():
from .session import changeProfile
changeProfile(notify=True)

def dispatch():
if _PARAMS.get('action'):
action = _PARAMS.get('action')
if action == 'logout':
from .session import startLogout
startLogout()
elif action == 'profile':
from .session import changeProfile
changeProfile(notify=True)
else:
mode = _PARAMS.get('menu', 'home')
dispatcher.run(mode)
route = _PARAMS.get('route', 'home')
dispatcher.run(route)
4 changes: 2 additions & 2 deletions resources/lib/views/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Base:
pages = False

"""
True if is an static menu with predefined items
True if is an static route with predefined items
"""
static = False

Expand Down Expand Up @@ -51,7 +51,7 @@ def show(self):
Renders folder depending of config
"""
listing = []
# Render static menu
# Render static route
if self.static:
listing = Render.static(self.items)
else:
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/views/MainMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class MainMenu(Base):
"""
Main menu, default menu. Does not have a path string
Main menu, default route. Does not have a path string
"""
static = True
items = [
Expand Down

0 comments on commit c9878d0

Please sign in to comment.