Skip to content

Commit

Permalink
0.2.0: add timeout to all requests
Browse files Browse the repository at this point in the history
  • Loading branch information
kuriho committed May 27, 2023
1 parent ba1cf1b commit 7cd7d94
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='UTF-8'?>
<addon id="plugin.video.tver" name="TVer" version="0.1.9" provider-name="kuriho">
<addon id="plugin.video.tver" name="TVer" version="0.2.0" provider-name="kuriho">

<requires>
<import addon="xbmc.python" version="3.0.1" />
Expand Down
7 changes: 1 addition & 6 deletions mylist.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,7 @@ def get_random_pic(self):
conn = sql.connect(self.file)
cur = conn.cursor()

stmt = '''
SELECT id,
vid_type
FROM mylist
ORDER BY RANDOM() LIMIT 1
'''
stmt = f'SELECT id, vid_type FROM mylist ORDER BY RANDOM() LIMIT 1'
cur.execute(stmt)

results = cur.fetchall()
Expand Down
4 changes: 2 additions & 2 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ def list_categories():
xbmcplugin.addSortMethod(_HANDLE, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(_HANDLE)

def play_video(path):
info = extract_info(path)
def play_video(video):
info = extract_info(video)
url = extract_manifest_url_from_info(info)

adaptive_type = False
Expand Down
8 changes: 5 additions & 3 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
from mylist import MyList

if __name__ == '__main__':
# cache warming
#initialize DB
mylist = MyList()
Cache().create()
mylist.create()

# cache warming
for (category, _, _) in tver.get_categories():
tver.fetch_episodes(category)

# build MyList
mylist = MyList()
mylist.create()
mylist.delete_expired()
mylist.build()
4 changes: 2 additions & 2 deletions tver.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def fetch_api_token():
'Origin': 'https://s.tver.jp',
'Referer': 'https://s.tver.jp/',
'Content-Type': 'application/x-www-form-urlencoded',
})
}, timeout=10)

json_token = resp.json()

Expand All @@ -43,7 +43,7 @@ def fetch_episodes(category):
return cached_episodes

(uid, token) = fetch_api_token()
resp = requests.get(URL_LIST_EPISODES.format(category, uid, token), headers={'x-tver-platform-type': 'web'})
resp = requests.get(URL_LIST_EPISODES.format(category, uid, token), headers={'x-tver-platform-type': 'web'}, timeout=10)
data = resp.json()

cache.insert(category, data)
Expand Down

0 comments on commit 7cd7d94

Please sign in to comment.