Fixes Issue #2 #4
@ -5,7 +5,6 @@ import re
|
|||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import requests
|
|
||||||
from requests.auth import HTTPBasicAuth
|
from requests.auth import HTTPBasicAuth
|
||||||
from requests.sessions import Session
|
from requests.sessions import Session
|
||||||
|
|
||||||
@ -49,7 +48,8 @@ class Mediasite:
|
|||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
mypackage['notification_id'] = data['id']
|
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.auth = self.auth
|
||||||
session.stream = True
|
session.stream = True
|
||||||
mypackage['thumb'] = self._download(base, data['thumb'], session)
|
mypackage['thumb'] = self._download(base, data['thumb'], session)
|
||||||
@ -66,11 +66,12 @@ class Mediasite:
|
|||||||
slides = []
|
slides = []
|
||||||
demux_file = os.path.join(slides_path, 'demux.txt')
|
demux_file = os.path.join(slides_path, 'demux.txt')
|
||||||
|
|
||||||
#offset = data['duration'] - int(data['slides'][-1]['duration'])
|
|
||||||
with open(demux_file, 'w') as f:
|
with open(demux_file, 'w') as f:
|
||||||
myslide = {}
|
myslide = {}
|
||||||
f.write('ffconcat version 1.0\n')
|
f.write('ffconcat version 1.0\n')
|
||||||
num_slides = len(data['slides'])
|
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):
|
for i in range(num_slides):
|
||||||
myslide['url'] = os.path.join(slides_path, self._download(slides_path, data['slides'][i]['url'], session))
|
myslide['url'] = os.path.join(slides_path, self._download(slides_path, data['slides'][i]['url'], session))
|
||||||
if i == num_slides - 1:
|
if i == num_slides - 1:
|
||||||
@ -80,7 +81,6 @@ class Mediasite:
|
|||||||
else:
|
else:
|
||||||
myslide['duration'] = '{}ms'.format(int(data['slides'][i+1]['duration']) - int(data['slides'][i]['duration']))
|
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('file \'{}\'\n'.format(myslide['url']))
|
||||||
f.write('duration {}\n'.format(myslide['duration']))
|
f.write('duration {}\n'.format(myslide['duration']))
|
||||||
slides.append(myslide)
|
slides.append(myslide)
|
||||||
@ -88,10 +88,11 @@ class Mediasite:
|
|||||||
# to accomodate for an ffmpeg quirk that needs the last slide twice
|
# to accomodate for an ffmpeg quirk that needs the last slide twice
|
||||||
f.write('file \'{}\'\n'.format(slides[-1]['url']))
|
f.write('file \'{}\'\n'.format(slides[-1]['url']))
|
||||||
mypackage['sources'].append({'demux_file': demux_file,
|
mypackage['sources'].append({'demux_file': demux_file,
|
||||||
'poster': slides[0]['url'],
|
'poster': slides[-1]['url'],
|
||||||
'playAudio': False })
|
'playAudio': False })
|
||||||
return mypackage
|
return mypackage
|
||||||
|
|
||||||
|
# function to download the material from mediasite
|
||||||
def _download(self, base, remotefile, session):
|
def _download(self, base, remotefile, session):
|
||||||
localname = remotefile.split('/')[-1]
|
localname = remotefile.split('/')[-1]
|
||||||
localpath = os.path.join(base, localname)
|
localpath = os.path.join(base, localname)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user