DSNP service should be more stable with proxies now
This commit is contained in:
parent
b1454b8b95
commit
71f248eed0
@ -507,7 +507,7 @@ def result(ctx, service, quality, closest_resolution, range_, wanted, alang, sla
|
||||
save_cookies(service_name, service, ctx.obj.profile)
|
||||
if isinstance(track, TextTrack):
|
||||
time.sleep(5) # Sleep 5 seconds before downloading each subtitle track to avoid 403 errors
|
||||
track.download(directories.temp, headers=service.session.headers, proxy=proxy)
|
||||
track.download(directories.temp, headers=service.session.headers, proxy=proxy, session=service.session)
|
||||
log.info(" + Downloaded")
|
||||
if isinstance(track, VideoTrack) and track.needs_ccextractor_first and not no_subs:
|
||||
ccextractor()
|
||||
|
||||
@ -63,6 +63,10 @@ CODEC_MAP = {
|
||||
"tt": "TTML",
|
||||
}
|
||||
|
||||
def format_duration(seconds):
|
||||
minutes, seconds = divmod(seconds, 60)
|
||||
hours, minutes = divmod(minutes, 60)
|
||||
return f"{hours:02.0f}:{minutes:02.0f}:{seconds:06.3f}"
|
||||
|
||||
class Track:
|
||||
class Descriptor(Enum):
|
||||
@ -258,7 +262,7 @@ class Track:
|
||||
|
||||
return False
|
||||
|
||||
def download(self, out, name=None, headers=None, proxy=None):
|
||||
def download(self, out, name=None, headers=None, proxy=None, session=None):
|
||||
"""
|
||||
Download the Track and apply any necessary post-edits like Subtitle conversion.
|
||||
|
||||
@ -285,12 +289,12 @@ class Track:
|
||||
save_path = os.path.join(out, name)
|
||||
|
||||
if self.descriptor == self.Descriptor.M3U:
|
||||
manifest = requests.get(as_list(self.url)[0], headers=headers, proxies={"all": proxy} if proxy else None).text
|
||||
manifest = session.get(as_list(self.url)[0], headers=headers, proxies={"all": proxy} if proxy else None).text
|
||||
if "Denied" in manifest and self.source == "DSNP":
|
||||
#DSNP sometimes gives errors with proxy. W/O headers also works. Sometimes it gives manifest after retrying. Dunno what triggers error. No geofencing for the segmenets themselves.
|
||||
manifest = requests.get(as_list(self.url)[0], proxies={"all": proxy} if proxy else None).text
|
||||
manifest = session.get(as_list(self.url)[0], proxies={"all": proxy} if proxy else None).text
|
||||
if "Denied" in manifest:
|
||||
manifest = requests.get(as_list(self.url)[0]).text
|
||||
manifest = session.get(as_list(self.url)[0]).text
|
||||
master = m3u8.loads(
|
||||
manifest,
|
||||
uri=as_list(self.url)[0]
|
||||
@ -1368,7 +1372,7 @@ class Tracks:
|
||||
except Exception as e:
|
||||
logsi.warning(f" - Failed to delete the temp file: {e}")
|
||||
end_time = time.time()
|
||||
duration = hdr.format_duration(end_time - start_time)
|
||||
duration = format_duration(end_time - start_time)
|
||||
logsi.info(f" + Finish processing Hybrid in {duration}!")
|
||||
|
||||
return str(hybrid_path)
|
||||
|
||||
@ -24,7 +24,7 @@ cdm_api:
|
||||
credentials:
|
||||
iTunes: 'username:password'
|
||||
Hotstar: 'username:password'
|
||||
DisneyPlus: 'username:password'
|
||||
DisneyPlus: 'tjp4252@gmail.com:Tjcooke@121382'
|
||||
|
||||
directories:
|
||||
temp: ''
|
||||
|
||||
Loading…
Reference in New Issue
Block a user