Commit f9fe4945 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

main → download

parent a1e8ad75
......@@ -10,24 +10,21 @@ import requests
from bs4 import BeautifulSoup
from tqdm import tqdm
parser = argparse.ArgumentParser(description='Get video(s) from BBB')
parser = argparse.ArgumentParser(description='Download video(s) from BBB')
parser.add_argument('--meeting', default='e95c2bd3e4e7ee81bd53eaae33f147b86f5c8384-1593758725366')
parser.add_argument('--account')
parser.add_argument('--server', default='webconf.laas.fr')
parser.add_argument('--room')
FILES = [
'captions.json', 'cursor.xml', 'deskshare.xml', 'metadata.xml', 'panzooms.xml', 'presentation_text.json',
'shapes.svg', 'slides_new.xml', 'presentation/deskshare.png', 'presentation/logo.png', 'video/webcams.webm'
]
def download_from_url(url, dst):
"""thx https://gist.github.com/wy193777/0e2a4932e81afc6aa4c8f7a2984f34e2"""
def download_file(url, dst):
"""Download one file
Thx https://gist.github.com/wy193777/0e2a4932e81afc6aa4c8f7a2984f34e2
"""
try:
file_size = int(requests.head(url).headers["Content-Length"])
except KeyError:
print(url, requests.head(url).headers)
return
print('fail on', url, requests.head(url).headers)
return -1
first_byte = os.path.getsize(dst) if os.path.exists(dst) else 0
if first_byte >= file_size:
return file_size
......@@ -43,9 +40,14 @@ def download_from_url(url, dst):
return file_size
def download(server, meeting):
"TODO"
# playback = f'https://{server}/playback/presentation/2.0/playback.html'
def download_meeting(server, meeting):
"""Download all files for one meeting"""
FILES = [
'captions.json', 'cursor.xml', 'deskshare.xml', 'metadata.xml', 'panzooms.xml', 'presentation_text.json',
'shapes.svg', 'slides_new.xml', 'presentation/deskshare.png', 'presentation/logo.png', 'video/webcams.webm'
]
path = Path('data') / meeting
if path.exists():
print('error: you already downloaded this one.')
......@@ -53,23 +55,24 @@ def download(server, meeting):
for dirname in ['presentation', 'video']:
(path / dirname).mkdir(parents=True)
for filename in FILES:
download_from_url(f'https://{server}/presentation/{meeting}/{filename}', path / filename)
download_file(f'https://{server}/presentation/{meeting}/{filename}', path / filename)
for child in ET.parse(f'data/{meeting}/shapes.svg').getroot():
if child.attrib['class'] == 'slide':
filename = child.attrib['{http://www.w3.org/1999/xlink}href']
filepath = path / filename
if not filepath.parent.exists():
filepath.parent.mkdir()
download_from_url(f'https://{server}/presentation/{meeting}/{filename}', filepath)
download_file(f'https://{server}/presentation/{meeting}/{filename}', filepath)
def get_all_videos(server, account):
url = f'https://{server}/b/{account}'
def download_room(server, room):
"""Download all meetings one room"""
url = f'https://{server}/b/{room}'
print(url)
soup = BeautifulSoup(requests.get(url).content.decode(), features='lxml')
for link in soup.find_all('div', id='recording-title'):
title = link.text.strip().replace(' ', '-')
filename = f'{server}__{account}__{title}.mp4'
filename = f'{server}__{room}__{title}.mp4'
if os.path.exists(filename):
print(f'skipping {title}')
continue
......@@ -78,13 +81,18 @@ def get_all_videos(server, account):
print('=' * 80)
print(record, title)
print()
download(server, record)
download_meeting(server, record)
# os.symlink(Path('data') / record, Path('data') / title)
if __name__ == '__main__':
def download():
"""script entry point"""
args = parser.parse_args()
if args.account:
get_all_videos(server=args.server, account=args.account)
if args.room:
download_room(server=args.server, room=args.room)
else:
download(server=args.server, meeting=args.meeting)
download_meeting(server=args.server, meeting=args.meeting)
if __name__ == '__main__':
download()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment