Fixes Issue #2 #4

Merged
dafo5502 merged 59 commits from developer into master 2021-10-25 14:41:37 +02:00
Showing only changes of commit 6306418038 - Show all commits

View File

@ -5,7 +5,6 @@ import re
import shutil
import logging
import requests
from requests.auth import HTTPBasicAuth
from requests.sessions import Session
@ -49,7 +48,8 @@ class Mediasite:
if 'id' in data:
mypackage['notification_id'] = data['id']
with requests.Session() as session:
# Create one session for all the downloads
with Session() as session:
session.auth = self.auth
session.stream = True
mypackage['thumb'] = self._download(base, data['thumb'], session)
@ -66,11 +66,12 @@ class Mediasite:
slides = []
demux_file = os.path.join(slides_path, 'demux.txt')
#offset = data['duration'] - int(data['slides'][-1]['duration'])
with open(demux_file, 'w') as f:
myslide = {}
f.write('ffconcat version 1.0\n')
num_slides = len(data['slides'])
# loop all slides and download, calculate the duration and create a text file holding all the info for he ffmpeg demuxer
for i in range(num_slides):
myslide['url'] = os.path.join(slides_path, self._download(slides_path, data['slides'][i]['url'], session))
if i == num_slides - 1:
@ -80,7 +81,6 @@ class Mediasite:
else:
myslide['duration'] = '{}ms'.format(int(data['slides'][i+1]['duration']) - int(data['slides'][i]['duration']))
#offset += int(data[['slides'][i]['duration']])
f.write('file \'{}\'\n'.format(myslide['url']))
f.write('duration {}\n'.format(myslide['duration']))
slides.append(myslide)
@ -88,10 +88,11 @@ class Mediasite:
# to accomodate for an ffmpeg quirk that needs the last slide twice
f.write('file \'{}\'\n'.format(slides[-1]['url']))
mypackage['sources'].append({'demux_file': demux_file,
'poster': slides[0]['url'],
'poster': slides[-1]['url'],
'playAudio': False })
return mypackage
# function to download the material from mediasite
def _download(self, base, remotefile, session):
localname = remotefile.split('/')[-1]
localpath = os.path.join(base, localname)