Skip to content

Commit

Permalink
Merge branch 'irill'
Browse files Browse the repository at this point in the history
  • Loading branch information
muellert committed Dec 21, 2012
2 parents 8b5b676 + 63604e7 commit bd1ce5e
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 44 deletions.
1 change: 1 addition & 0 deletions on/video/browser/videogallery.py
Expand Up @@ -118,6 +118,7 @@ def genSmallView(item, request = None):
result['thumb'] = vtn.thumbnail()
titles = shorttitle(item.title)
result['title'] = titles['short']
result['director'] = item.director
result['longtitle'] = titles['long']

elif item.portal_type == 'Image':
Expand Down
13 changes: 8 additions & 5 deletions on/video/browser/videogallery_templates/videogallery.pt
Expand Up @@ -20,14 +20,14 @@
Batch python:modules['Products.CMFPlone'].Batch;
foldercontents view/contents;
b_start python:request.get('b_start', 0);
batch python:isinstance(foldercontents, Batch) and foldercontents or Batch(foldercontents, limit_display or 15, b_start, orphan=1);
batch python:isinstance(foldercontents, Batch) and foldercontents or Batch(foldercontents, limit_display or 12, b_start, orphan=1);
normalizeString nocall: context/plone_utils/normalizeString;
navigation_root_url context/@@plone_portal_state/navigation_root_url">
<tal:listing condition="batch">

<div metal:use-macro="context/batch_macros/macros/navigation" />

<div tal:repeat="item batch">
<div class="videogallerycontainer" tal:repeat="item batch">
<div tal:define="odd repeat/item/odd; ltitle item/longtitle"
tal:attributes="class python:odd and 'even' or 'odd'">
<a href="#" titles="#" tal:attributes="href item/path; title ltitle;" class="videothumb">
Expand All @@ -36,11 +36,14 @@
</a>
<br />
<div tal:condition="python:item['portaltype'] == 'Folder'"
class="videodesc">
<span tal:replace="item/sub_folder" /> galleries, <span tal:replace="item/sub_videos" /> videos
class="videodesc"><span tal:condition="item/sub_folder" tal:omit-tag="">
<span tal:replace="item/sub_folder" /> galleries, </span><span tal:replace="item/sub_videos" /> videos
</div>
<div tal:condition="python:item['portaltype'] == 'on.video.Video' and len(item['director'])"
class="videodirector"> by <span tal:content="item/director" />
</div>
<div tal:condition="python:item['portaltype'] == 'on.video.Video'"
class="videodesc">
class="videoplayingtime">
Duration: <span tal:replace="item/playingtime" />
</div>

Expand Down
Binary file added on/video/static/invalidmetafile.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 45 additions & 39 deletions on/video/video.py
Expand Up @@ -36,7 +36,7 @@ class IVideo(form.Schema):
)

director = schema.TextLine(
title=_(u"Author/Director"),
title=_(u"Author"),
required=False,
)

Expand Down Expand Up @@ -277,44 +277,50 @@ def parseMetadataFileContents(lines, urlbase, fspath, filename, vo = O(), player
return vo

vo.thumbnailurl = None
line = lines.pop(0)
thumb = line.split(':', 1)
if thumb[0].strip() == 'thumbnail' and len(thumb) > 1 and thumb[1].strip() != '':
vo.thumbnailurl = genUrl(urlbase, vo.urlprefix, thumb[1].strip())
line = lines.pop(0)
ptime = line.split(':', 1)
if ptime[0].strip() == 'playing time' and len(ptime) > 1:
pt = re.search('(\d+:\d\d:\d\d)', ptime[1])
if pt:
vo.playing_time = pt.group()
try:

line = lines.pop(0)
thumb = line.split(':', 1)
if thumb[0].strip() == 'thumbnail' and len(thumb) > 1 and thumb[1].strip() != '':
vo.thumbnailurl = genUrl(urlbase, vo.urlprefix, thumb[1].strip())
line = lines.pop(0)
ptime = line.split(':', 1)
if ptime[0].strip() == 'playing time' and len(ptime) > 1:
pt = re.search('(\d+:\d\d:\d\d)', ptime[1])
if pt:
vo.playing_time = pt.group()
else:
vo.playing_time = 'unknown' #None #'0:00:00' # unnown playing time
else:
vo.playing_time = 'unknown' #None #'0:00:00' # unnown playing time
else:
lines.insert(0, line) # preserve the unused line

vo.player = urlbase + player
# playing time:
# set url to the video that should be played inline (how to manage different sizes?):
line = lines.pop(0)
svid = line.split(':', 1)

# Algorithm:
# We need to select an MP4 format video for direct play, if possible.
# To arrive at a consistent list of video files to play/download, we
# only remember the file name of the selected video and see, whether
# it occurs again later down the road (eg. should there be multiple
# MP4 videos available).
vo.directplay = None
directplay = None
#print "*** readVideoMetaData(), urlprefix = ", vo.urlprefix
if svid[0].strip() == 'selected':
vf = None
if len(svid) > 1:
vf = svid[1].strip()
if len(vf) > 1 and vf[0] == '/':
vf = vf[1:]
if len(vf) and os.path.exists(os.path.join(fspath, vo.urlprefix, vf)):
directplay = vf
lines.insert(0, line) # preserve the unused line

vo.player = urlbase + player
# playing time:
# set url to the video that should be played inline (how to manage different sizes?):
line = lines.pop(0)
svid = line.split(':', 1)

# Algorithm:
# We need to select an MP4 format video for direct play, if possible.
# To arrive at a consistent list of video files to play/download, we
# only remember the file name of the selected video and see, whether
# it occurs again later down the road (eg. should there be multiple
# MP4 videos available).
vo.directplay = None
directplay = None
#print "*** readVideoMetaData(), urlprefix = ", vo.urlprefix
if svid[0].strip() == 'selected':
vf = None
if len(svid) > 1:
vf = svid[1].strip()
if len(vf) > 1 and vf[0] == '/':
vf = vf[1:]
if len(vf) and os.path.exists(os.path.join(fspath, vo.urlprefix, vf)):
directplay = vf
except:
setDefaultNoVideoValues(vo)
vo.thumbnailurl = '/++resource++on.video/invalidmetafile.png'
return vo

vo.x = DEFAULT_WIDTH
vo.y = DEFAULT_HEIGHT
Expand Down Expand Up @@ -486,7 +492,7 @@ def validateFilename(value):
@form.validator(field=IVideo['recorded'])
def validateRecorded(value):
"""Raise an exception if the recording date lies in the future."""
if value > datetime.now():
if value is not None and value > datetime.now():
raise Invalid(u"The video could not have been recorded in the future.")

# raise schema.ValidationError(u"The video could not have been recorded in the future.")
Expand Down

0 comments on commit bd1ce5e

Please sign in to comment.