77from urllib .request import getproxies
88from pathlib import Path
99
10- import browser_cookie3
1110import websocket
1211from rich .console import Console
1312from rich .table import Table
@@ -28,18 +27,10 @@ def validate_cookie(cookies):
2827 else :
2928 print (f'WARN: Cannot find user_session in cookie. You\' re probably not logged in.' )
3029 # exit(1) # make it non-fatal
31-
32- if cookies .lower () in ['chrome' , 'firefox' , 'edge' ]:
33- print (f'Fetching cookies from browser { cookies } ...' )
34- cookies = cookies .lower ()
35- if cookies == 'chrome' :
36- cookies = browser_cookie3 .chrome (domain_name = '.nicovideo.jp' )
37- elif cookies == 'firefox' :
38- cookies = browser_cookie3 .firefox (domain_name = '.nicovideo.jp' )
39- elif cookies == 'edge' :
40- cookies = browser_cookie3 .edge (domain_name = '.nicovideo.jp' )
30+ if isinstance (cookies , str ) and cookies .lower () in ['chrome' , 'firefox' , 'edge' ]:
31+ cookies = load_cookie (cookies + '/nicovideo.jp' )
4132 validate_cookie (cookies )
42- elif cookies .startswith ('user_session_' ):
33+ elif isinstance ( cookies , str ) and cookies .startswith ('user_session_' ):
4334 cookies = {'user_session' : cookies }
4435 elif Path (cookies ).exists ():
4536 print (f'Loading cookies from file { cookies } ...' )
@@ -59,10 +50,10 @@ def validate_cookie(cookies):
5950 elif proxy == 'auto' :
6051 proxies = getproxies ()
6152 if proxy := proxies .get ('http' ):
62- print (f'INFO: automatically use system proxy { proxy } ' )
63-
53+ print (f'INFO: Automatically use system proxy { proxy } ' )
6454 # I don't think system proxy would be missing scheme, but just in case
6555 if proxy and '://' not in proxy :
56+ print ('WARN: Proxy is missing scheme. Assuming http://' )
6657 proxy = f'http://{ proxy } '
6758
6859 self .session .proxies = {'http' : proxy , 'https' : proxy }
@@ -253,7 +244,8 @@ def download_timeshift(self, url_or_video_id, info_only=False, comments='yes', v
253244 room_info = None
254245 stream_info = None
255246
256- ex = concurrent .futures .ThreadPoolExecutor (max_workers = 1 )
247+ #TODO: fix danmaku downloading with the new method
248+ # ex = concurrent.futures.ThreadPoolExecutor(max_workers=1)
257249
258250 while True :
259251 verbose and print ("Receiving..." )
@@ -263,6 +255,7 @@ def download_timeshift(self, url_or_video_id, info_only=False, comments='yes', v
263255 if data ['type' ] == 'stream' :
264256 stream_info = data
265257 break
258+ #TODO: danmaku downloading is temporarily disabled until the new method is implemented
266259 # if data['type'] == 'room':
267260 # room_info = data
268261 # if comments in ['yes', 'only']:
@@ -315,7 +308,8 @@ def download_timeshift(self, url_or_video_id, info_only=False, comments='yes', v
315308 print ('CMD is:' )
316309 print (cmd )
317310 run (cmd , shell = True )
318- ex .shutdown (wait = True ) # ensure download_comments is finished
311+ # TODO: fix danmaku downloading with the new method
312+ # ex.shutdown(wait=True) # ensure download_comments is finished
319313
320314 return_value .update ({
321315 'master_m3u8_url' : master_m3u8_url ,
0 commit comments