def main(): """Dispatches the commands.""" handler = PutioApiHandler(SETTINGS.getSetting('oauth2_token')) item_id = PLUGIN_ARGS.get('item') if not item_id: # Entrypoint. # if the user has an account but no product, # she could walk the files but couldn't play them. Inform. if not handler.is_account_active(): xbmcgui.Dialog().ok(heading=I18N(32062), line1=I18N(32063)) populate_dir(handler.list(parent=0)) return item_id = int(item_id[0]) item = handler.get(id_=item_id) if not item.content_type: return # Dispatch commands action = PLUGIN_ARGS.get('action') if not action: return action = action[0] if action == 'list': populate_dir(handler.list(parent=item_id)) return if action == 'delete': delete(item=item) return if action == 'play': play(item=item) return
continue # don't even bother to send a request if the player is at the start of the video. if video_is_at < 10: continue video_duration = player.getTotalTime() if video_duration <= 20: continue # if the player is very close to finish, set the 'start_from' parameter to the send of the video. because our # poll interval is not very precise. just assume user has finished watching the video. if (video_duration - video_is_at) < POLL_INTERVAL: video_is_at = video_duration oauth2_token = SETTINGS.getSetting('oauth2_token') if not oauth2_token: xbmc.log(msg='[putio.service] Missing OAuth2 Token', level=xbmc.LOGERROR) continue # FIXME: urlparse combined with os.path.split gives a stupid error. this is python 2.6 in 2016. screw this. paths = filename.strip(PUTIO_API_ENDPOINT) item_id = paths.split('/')[1] # time to send a request handler = Client(access_token=oauth2_token, use_retry=True) try: handler.request('/files/%s/start-from/set' % item_id, method='POST', data={'time': video_is_at}) except Exception as e: