mirror of
https://cdm-project.com/Download-Tools/udemy-downloader.git
synced 2025-04-30 02:04:27 +02:00
Update to fix time extraction
Replaced inconsistent regular expression evaluation with string based operation.
This commit is contained in:
parent
d5fbdf10f4
commit
2b83a1536a
@ -1,5 +1,5 @@
|
||||
#dashdrmmultisegmentdownloader
|
||||
import os,requests,shutil,json,glob,re
|
||||
import os,requests,shutil,json,glob
|
||||
from mpegdash.parser import MPEGDASHParser
|
||||
from mpegdash.nodes import Descriptor
|
||||
from mpegdash.utils import (
|
||||
@ -14,7 +14,7 @@ working_dir = os.getcwd() + "\working_dir" # set the folder to download ephemera
|
||||
keyfile_path = download_dir + "\keyfile_test.json"
|
||||
|
||||
if not os.path.exists(working_dir):
|
||||
os.makedirs()
|
||||
os.makedirs(working_dir)
|
||||
|
||||
#Get the keys
|
||||
with open(keyfile_path,'r') as keyfile:
|
||||
@ -45,20 +45,15 @@ Descriptor.__init__ = __init__
|
||||
Descriptor.parse = parse
|
||||
Descriptor.write = write
|
||||
|
||||
#Compiled regex time
|
||||
days = re.compile("([\d.]+)D")
|
||||
hours = re.compile("([\d.]+)H")
|
||||
minutes = re.compile("([\d.]+)M")
|
||||
seconds = re.compile("([\d.]+)S")
|
||||
|
||||
def durationtoseconds(period):
|
||||
#Duration format in PTxDxHxMxS
|
||||
if(period[:2] == "PT"):
|
||||
period = period[2:]
|
||||
day = int(days.match(period).group(1)) if days.match(period) else 0 # Probably never happens
|
||||
hour = int(hours.match(period).group(1)) if hours.match(period) else 0
|
||||
minute = int(minutes.match(period).group(1)) if minutes.match(period) else 0
|
||||
second = seconds.match(period).group(1)
|
||||
day = int(period.split("D")[0] if 'D' in period else 0)
|
||||
hour = int(period.split("H")[0].split("D")[-1] if 'H' in period else 0)
|
||||
minute = int(period.split("M")[0].split("H")[-1] if 'M' in period else 0)
|
||||
second = period.split("S")[0].split("M")[-1]
|
||||
print(day,hour,minute,second)
|
||||
total_time = float(str((day * 24 * 60 * 60) + (hour * 60 * 60) + (minute * 60) + (int(second.split('.')[0]))) + '.' + str(int(second.split('.')[-1])))
|
||||
return total_time
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user