dlg = xbmcgui.Dialog()
return dlg.numeric(heading=self.get_local_string(string_id=30019) + ' ' + self.get_local_string(string_id=30022), type=0)
- def show_adult_pin_dialog (self):
- """Asks the user for the adult pin
-
- Returns
- -------
- :obj:`int`
- 4 digit adult pin needed for adult movies
- """
- dlg = xbmcgui.Dialog()
- return dlg.input(self.get_local_string(string_id=30002), type=xbmcgui.INPUT_NUMERIC)
-
def show_search_term_dialog (self):
"""Asks the user for a term to query the netflix search for
dlg = xbmcgui.Dialog()
return dlg.input(self.get_local_string(string_id=30005), type=xbmcgui.INPUT_ALPHANUM)
- def show_wrong_adult_pin_notification (self):
- """Shows notification that a wrong adult pin was given
-
- Returns
- -------
- bool
- Dialog shown
- """
- dialog = xbmcgui.Dialog()
- dialog.notification(self.get_local_string(string_id=30006), self.get_local_string(string_id=30007), xbmcgui.NOTIFICATION_ERROR, 5000)
- return True
-
def show_login_failed_notification (self):
"""Shows notification that the login failed
if video_list[video_list_id]['type'] == 'movie':
# it´s a movie, so we need no subfolder & a route to play it
isFolder = False
- # check maturity index, to determine if we need the adult pin
- needs_pin = (True, False)[int(video['maturity']['level']) >= 1000]
- url = build_url({'action': 'play_video', 'video_id': video_list_id, 'pin': needs_pin})
+ url = build_url({'action': 'play_video', 'video_id': video_list_id})
# add list item info
li = self._generate_entry_info(entry=video, li=li)
li = self._generate_context_menu_items(entry=video, li=li)
# add list item info
li = self._generate_entry_info(entry=episode, li=li, base_info={'mediatype': 'episode'})
li = self._generate_context_menu_items(entry=episode, li=li)
- # check maturity index, to determine if we need the adult pin
- needs_pin = (True, False)[int(episode['maturity']['rating']['maturityLevel']) >= 1000]
- url = build_url({'action': 'play_video', 'video_id': episode_id, 'pin': needs_pin, 'start_offset': episode['bookmark']})
+ url = build_url({'action': 'play_video', 'video_id': episode_id, 'start_offset': episode['bookmark']})
xbmcplugin.addDirectoryItem(handle=self.plugin_handle, url=url, listitem=li, isFolder=False)
xbmcplugin.addSortMethod(handle=self.plugin_handle, sortMethod=xbmcplugin.SORT_METHOD_EPISODE)
# check if we have a bookmark e.g. start offset position
if int(start_offset) > 0:
- play_item.setProperty('StartOffset', str(start_offset))
+ play_item.setProperty('StartOffset', str(start_offset) + '.0')
return xbmcplugin.setResolvedUrl(self.plugin_handle, True, listitem=play_item)
def _generate_art_info (self, entry, li):
episode_entry = 'S%02dE%02d' % (season, episode)
return episode_entry in show_entry['episodes']
- def add_movie (self, title, alt_title, year, video_id, pin, build_url):
+ def add_movie (self, title, alt_title, year, video_id, build_url):
"""Adds a movie to the local db, generates & persists the strm file
Parameters
video_id : :obj:`str`
ID of the video to be played
- pin : bool
- Needs adult pin
-
build_url : :obj:`fn`
Function to generate the stream url
"""
if self.movie_exists(title=title, year=year) == False:
self.db[self.movies_label][movie_meta] = {'alt_title': alt_title}
self._update_local_db(filename=self.db_filepath, db=self.db)
- self.write_strm_file(path=filename, url=build_url({'action': 'play_video', 'video_id': video_id, 'pin': pin}))
+ self.write_strm_file(path=filename, url=build_url({'action': 'play_video', 'video_id': video_id}))
def add_show (self, title, alt_title, episodes, build_url):
"""Adds a show to the local db, generates & persists the strm files
if self.show_exists(title) == False:
self.db[self.series_label][show_meta] = {'seasons': [], 'episodes': [], 'alt_title': alt_title}
for episode in episodes:
- self._add_episode(show_dir=show_dir, title=title, season=episode['season'], episode=episode['episode'], video_id=episode['id'], pin=episode['pin'], build_url=build_url)
+ self._add_episode(show_dir=show_dir, title=title, season=episode['season'], episode=episode['episode'], video_id=episode['id'], build_url=build_url)
self._update_local_db(filename=self.db_filepath, db=self.db)
return show_dir
- def _add_episode (self, title, show_dir, season, episode, video_id, pin, build_url):
+ def _add_episode (self, title, show_dir, season, episode, video_id, build_url):
"""Adds a single episode to the local DB, generates & persists the strm file
Parameters
video_id : :obj:`str`
ID of the video to be played
- pin : bool
- Needs adult pin
-
build_url : :obj:`fn`
Function to generate the stream url
"""
filepath = os.path.join(show_dir, filename)
if os.path.exists(filepath):
return
- self.write_strm_file(path=filepath, url=build_url({'action': 'play_video', 'video_id': video_id, 'pin': pin}))
+ self.write_strm_file(path=filepath, url=build_url({'action': 'play_video', 'video_id': video_id}))
def remove_movie (self, title, year):
"""Removes the DB entry & the strm file for the movie given
# display the lists (recommendations, genres, etc.)
return self.show_user_list(type=params['type'])
elif params['action'] == 'play_video':
- # play a video, check for adult pin if needed
- adult_pin = None
- if self.check_for_adult_pin(params=params):
- adult_pin = self.kodi_helper.show_adult_pin_dialog()
- if self.netflix_session.send_adult_pin(pin=adult_pin) != True:
- return self.kodi_helper.show_wrong_adult_pin_notification()
self.play_video(video_id=params['video_id'], start_offset=params.get('start_offset', -1))
elif params['action'] == 'user-items' and params['type'] == 'search':
# if the user requested a search, ask for the term
video = metadata['video']
if video['type'] == 'movie':
- self.library.add_movie(title=video['title'], alt_title=alt_title, year=video['year'], video_id=video_id, pin=video['requiresPin'], build_url=self.build_url)
+ self.library.add_movie(title=video['title'], alt_title=alt_title, year=video['year'], video_id=video_id, build_url=self.build_url)
if video['type'] == 'show':
episodes = []
for season in video['seasons']:
for episode in season['episodes']:
- episodes.append({'season': season['seq'], 'episode': episode['seq'], 'id': episode['id'], 'pin': episode['requiresAdultVerification']})
+ episodes.append({'season': season['seq'], 'episode': episode['seq'], 'id': episode['id']})
self.library.add_show(title=video['title'], alt_title=alt_title, episodes=episodes, build_url=self.build_url)
return self.kodi_helper.refresh()
current_profile_id = self.netflix_session.user_data['guid']
return 'profile_id' in params and current_profile_id != params['profile_id']
- def check_for_adult_pin (self, params):
- """Checks if an adult pin is given in the query params
-
- Parameters
- ----------
- params : :obj:`dict` of :obj:`str`
- Url query params
-
- Returns
- -------
- bool
- Adult pin parameter exists or not
- """
- return (True, False)[params['pin'] == 'True']
-
def parse_paramters (self, paramstring):
"""Tiny helper to convert a url paramstring into a dictionary