comparison sat_website/media.py @ 92:7a79cb5ed43b

add subtitles in video metadata and <track /> elements
author souliane <souliane@mailoo.org>
date Tue, 16 Jun 2015 20:31:16 +0200
parents 5de2a3dd4e67
children 9ae3d9c8b28a
comparison
equal deleted inserted replaced
91:2de2c50a796d 92:7a79cb5ed43b
23 from django.conf import settings 23 from django.conf import settings
24 from collections import namedtuple, OrderedDict 24 from collections import namedtuple, OrderedDict
25 import os.path 25 import os.path
26 26
27 ImageDesc = namedtuple("ImageDesc", "path description data") 27 ImageDesc = namedtuple("ImageDesc", "path description data")
28 VideoDesc = namedtuple("VideoDesc", "paths description poster data") 28
29 class VideoDesc(namedtuple("VideoDesc", "paths description poster data")):
30 @property
31 def subtitles(self):
32 key = _(u"subtitles")
33 if key not in self.data:
34 return {}
35 result = OrderedDict()
36 for lang in self.data[key]:
37 try:
38 result[lang] = os.path.splitext(self.paths[lang])[0] + '.vtt'
39 except IndexError:
40 # FIXME: subtitles for a lang that is not in self.paths are ignored
41 pass
42 return result
29 43
30 screencasts = os.path.join(settings.MEDIA_EXTERNAL_URL, "screencasts") + "/" 44 screencasts = os.path.join(settings.MEDIA_EXTERNAL_URL, "screencasts") + "/"
31 video = os.path.join(settings.MEDIA_EXTERNAL_URL, "video") + "/" 45 video = os.path.join(settings.MEDIA_EXTERNAL_URL, "video") + "/"
32 46
33 #list the pictures 47 #list the pictures
37 # use OrderedDict when more than one language, the first item is the default one 51 # use OrderedDict when more than one language, the first item is the default one
38 VideoDesc(OrderedDict({"en": video + "libervia_adhesion_2015_en.webm", 52 VideoDesc(OrderedDict({"en": video + "libervia_adhesion_2015_en.webm",
39 "fr": video + "libervia_adhesion_2015_fr.webm"}), 53 "fr": video + "libervia_adhesion_2015_fr.webm"}),
40 _(u"Membership campaign for Libervia"), 54 _(u"Membership campaign for Libervia"),
41 video + "posters/libervia_adhesion_2015.png", 55 video + "posters/libervia_adhesion_2015.png",
42 {_(u"version"): "0.5", _(u"year"): "2015"}), 56 {_(u"version"): "0.5", _(u"year"): "2015", _(u"subtitles"): ["en", "fr"]}),
43 57
44 ImageDesc("images/screenshots/0.5/overview_libervia.png", _(u"Overview"), 58 ImageDesc("images/screenshots/0.5/overview_libervia.png", _(u"Overview"),
45 {_(u"frontend"): "libervia", _(u"version"): "0.5", _(u"year"): "2014"}), 59 {_(u"frontend"): "libervia", _(u"version"): "0.5", _(u"year"): "2014"}),
46 ImageDesc("images/screenshots/0.5/http_unsecure_warning.png", _(u"Optional security check"), 60 ImageDesc("images/screenshots/0.5/http_unsecure_warning.png", _(u"Optional security check"),
47 {_(u"frontend"): "libervia", _(u"version"): "0.5", _(u"year"): "2014"}), 61 {_(u"frontend"): "libervia", _(u"version"): "0.5", _(u"year"): "2014"}),