Commit 0f087980 authored by Stefano Rivera's avatar Stefano Rivera

Default to ogv

parent ecc108df
......@@ -17,14 +17,14 @@ from utils.objects import Conference, Event, Meta, VideoFormat
from utils.yaml import yaml_dump
def scrape(url, mpeg):
def scrape(url, args):
r = requests.get(url)
tree = ElementTree.fromstring(r.content)
videos = list(scrape_videos(tree, mpeg))
videos = list(scrape_videos(tree, args))
videos.sort(key=lambda event: event.start)
return Meta(
conference=scrape_conference(url, tree.find('conference'), mpeg),
conference=scrape_conference(url, tree.find('conference'), args),
videos=videos,
)
......@@ -54,7 +54,7 @@ def index_files(conference):
return index
def scrape_videos(tree, mpeg):
def scrape_videos(tree, args):
for day in tree.iter('day'):
date = dateutil.parser.parse(day.attrib['date']).date()
print('Date:', date)
......@@ -81,12 +81,15 @@ def scrape_videos(tree, mpeg):
room=penta_event.find('room').text,
start=start,
end=end,
video='high/{}.ogg'.format(video),
video='high/{}.ogv'.format(video),
alt_formats={
'low': 'low/{}.ogg'.format(video),
'low': 'low/{}.ogv'.format(video),
},
)
if mpeg:
if args.ogg:
event.video = 'high/{}.ogg'.format(video)
event.alt_formats['low'] = 'low/{}.ogg'.format(video)
if args.mpeg:
event.alt_formats.update({
'mpeg-ntsc': 'ntsc-dvd/{}.mpeg'.format(video),
'mpeg-pal': 'pal-dvd/{}.mpeg'.format(video),
......@@ -97,12 +100,13 @@ def scrape_videos(tree, mpeg):
event.language = {
'English': 'eng',
'en': 'eng',
'es': 'spa',
}[penta_lang]
yield event
def scrape_conference(url, penta_conf, mpeg):
def scrape_conference(url, penta_conf, args):
title = penta_conf.find('title').text
edition = int(re.search('\d+$', title).group(0))
start = dateutil.parser.parse(penta_conf.find('start').text).date()
......@@ -124,7 +128,7 @@ def scrape_conference(url, penta_conf, mpeg):
acodec='vorbis',
),
}
if mpeg:
if args.mpeg:
video_formats['mpeg-ntsc'] = VideoFormat(
resolution='352x240',
bitrate='400k',
......@@ -159,9 +163,11 @@ def main():
parser.add_argument('url', help='Pentabarf XML feed URL')
parser.add_argument('--mpeg', action='store_true',
help='Include mpeg formats')
parser.add_argument('--ogg', action='store_true',
help='Use .ogg extension')
args = parser.parse_args()
meta = scrape(args.url, args.mpeg)
meta = scrape(args.url, args)
with open('scraped.yml', 'w') as f:
yaml_dump(meta, f)
......
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