[Debconf-video-commits] r420 - in package/branches/pycon09/src: . media pyconvideo/pyconvideo
Ryan Verner
xf-guest at alioth.debian.org
Tue Apr 14 07:02:46 UTC 2009
Author: xf-guest
Date: 2009-04-14 07:02:46 +0000 (Tue, 14 Apr 2009)
New Revision: 420
Modified:
package/branches/pycon09/src/dc-publish
package/branches/pycon09/src/dc-video-schema.sql
package/branches/pycon09/src/media/style.css
package/branches/pycon09/src/pyconvideo/pyconvideo/admin.py
package/branches/pycon09/src/pyconvideo/pyconvideo/models.py
package/branches/pycon09/src/pyconvideo/pyconvideo/videotargetfile_list.html
Log:
Various updates to web interface, schema, publish script, etc
Modified: package/branches/pycon09/src/dc-publish
===================================================================
--- package/branches/pycon09/src/dc-publish 2009-04-01 09:01:06 UTC (rev 419)
+++ package/branches/pycon09/src/dc-publish 2009-04-14 07:02:46 UTC (rev 420)
@@ -1,167 +1,111 @@
-#!/usr/bin/python
+#!/usr/bin/env python
-import mx.DateTime
-import os
-import os.path
+# ryan at uanywhere.com.au
+
+import os, sys
+import datetime
+import blip, twitterpost
import re
-import sys
+import datetime
+import glob
+import csv
-if __name__ == '__main__':
- sys.path.insert(0, '/usr/share/debconf-video-store')
-from debconfvideo import config, database
+from pyconvideo.pyconvideo import models
+from django.db import transaction
-# metadata
-author = 'DebConf video team'
-licence = 'DebConf video licence; http://meetings-archive.debian.net/pub/debian-meetings/LICENCE'
+#blipuser='user'
+#blippass='pass'
-format_abbr = 'low' # format to link to
-#video_base_url = 'http://meetings-archive.debian.net/pub/debian-meetings/2007/debconf7/'
-#info_url_format = 'https://penta.debconf.org/~joerg/events/%(event_id)d.en.html'
-video_base_url = 'http://meetings-archive.debian.net/pub/debian-meetings/2008/debconf8/'
-info_url_format = 'https://penta.debconf.org/dc8_schedule/events/%(event_id)d.en.html'
+csvfile='/video/multipart-uploaded.csv'
+writerA = csv.writer(file(csvfile, "a"), delimiter=",", quotechar="\"")
-time_format = '%a, %d %b %Y %H:%M:%S GMT'
+# in kb - slightly under 1GB
+maxfilesize=1024000
-def esc_content(s):
- return s.replace('&', '&').replace('<', '<')
+def to_be_published():
+ for e in models.VideoTargetFile.objects.all():
+ multifile = 0
+ if e.published_time:
+ print "Skipping DB entry %s" % str(e.id)
+ continue
+ if e.file_status_id > 1 and e.file_status_id < 5:
+ print "Parsing DB entry " + str(e.id)
+ eventid = e.event_id
+ eventname = str([y.title for y in models.Event.objects.filter(event_id=eventid)][0])
+ eventdesc = [y.description for y in models.Event.objects.filter(event_id=eventid)][0].encode("utf-8")
+ targetformat = str(e.target_format)
+ filename = str(e.target_filename)
-def esc_attr(s):
- return s.replace('&', '&').replace('>', '>').replace("'", '"')
+ if targetformat == 'high-mpeg4':
+ filenamebase = os.path.basename(filename)
-def timestamp(s):
- return mx.DateTime.strptime(s, '%Y-%m-%d %H:%M:%S')
+ if os.path.getsize(filename) > (maxfilesize*1024):
+ print "File is over 1GB - needs to be split"
+ filename2 = "/video/high-mpeg4-split/" + filenamebase
+ cline = "cp %s %s && MP4Box -splits %s %s ; rm -f %s" % (filename, filename2, maxfilesize, filename2, filename2)
+ multifile = 1
+
+ else:
+ print "File is under 1GB"
+ filename2 = "/video/high-mpeg4-faststart/" + filenamebase
+ cline = "qt-faststart %s %s " % (filename, filename2)
-def interval(s):
- return mx.DateTime.TimeDelta(*[float(part) for part in s.split(':')])
+ print "Attempting to convert file: " + cline
+ os.system(cline)
-def make_rss(config, cur):
- conference_title = config['CONFERENCE_NAME']
- cur.execute('SELECT conference_id, homepage, timezone FROM conference'
- ' WHERE title = %(title)s',
- {'title': conference_title})
- conference_id, homepage, timezone = cur.fetchone()
- os.environ['TZ'] = timezone
- cur.execute("SELECT target_format_abbr, filename_extension FROM video_target_format"
- " WHERE published = true")
- published_formats = cur.fetchall()
+ # UNCOMMENT BELOW TO DISABLE MULTIFILE UPLOADS
+ # if multifile:
+ # print "Skipping upload for this file"
+ # continue
- rss = open(config['FILE_BASE'] + '/index.rss', 'w')
+ if e.file_status_id > 2:
+ print "Video has issues"
+ description = "[VIDEO HAS ISSUES: %s] %s" % (str(e.comments), str(eventdesc))
+ else:
+ print "Video has no issues"
+ description = eventdesc
- print >>rss, "<?xml version='1.0'?>"
- print >>rss, "<rss version='2.0' xmlns:media='http://search.yahoo.com/mrss/'>"
- print >>rss, "<channel>"
+ print "Attempting to publish: %s - %s - %s" % (str(eventid), filename2, eventname)
+ print description
- print >>rss, "<title>%s</title>" % esc_content(conference_title)
- print >>rss, "<link>%s</link>" % esc_content(homepage)
- print >>rss, "<description>%s</description>" % esc_content(conference_title)
- print >>rss, "<language>en</language>"
- print >>rss, "<copyright>Copyright %s. Licence: %s</copyright>" % (esc_content(author), esc_content(licence))
- print >>rss, "<generator>dc-make-rss</generator>"
+ blipid = ""
- cur.execute("""
-SELECT published_time, video_event_recording.start_time,
- video_event_recording.end_time, event_recording_base_name,
- event.event_id, title, description
-FROM
-((((video_target_file JOIN video_event_recording
- ON video_target_file.event_recording_id = video_event_recording.id)
- JOIN event
- ON video_event_recording.event_id = event.event_id)
- JOIN video_recording
- ON video_event_recording.recording_id = video_recording.id)
- JOIN video_target_format
- ON video_target_file.target_format_id = video_target_format.id)
-WHERE event.conference_id = %(conference_id)s
- AND video_target_format.published
- AND published_time IS NOT NULL
-ORDER BY conference_day ASC, published_time DESC
-""",
- {'conference_id': conference_id})
- for (published_time, start_time, end_time, base_name,
- event_id, title, event_desc) in cur.fetchall():
- # Convert string date-times back to proper types
- published_time = timestamp(published_time.split ('.')[0])
- start_time = interval(start_time)
- end_time = interval(end_time)
+ if multifile:
+ print "MULTIFILE"
+ event_url = str([y.source_url for y in models.Event.objects.filter(event_id=e.event_id)][0])
+ multipartname = glob.glob(("/video/high-mpeg4-split/%s_*.mp4" % os.path.splitext(filenamebase)[0]))
+ print multipartname
+ for partfile in multipartname:
+ partno = os.path.splitext((partfile.split("_")[-1]))[0]
+ posteventname = "%s (Part %s)" % (eventname, partno)
+ print "%s - %s - %s" % (str(partno), posteventname, partfile)
+ blipurl = begin_pycon_upload(e, blipid, blipuser, blippass, posteventname, description, partfile)
+ writerA.writerow((blipurl, event_url, partno))
+ e.save()
+
+ else:
+ # single part upload stuff here
+ begin_pycon_upload(e, blipid, blipuser, blippass, eventname, description, filename2)
+ e.save()
- info_url = info_url_format % {'conference_id': conference_id,
- 'event_id': event_id}
- description = ("""<h4>%s</h4>
- <p><a href='%s'>Full event details</a>"""
- % (esc_content(title),
- esc_attr(info_url)))
+ print "\n"
- for (format_abbr, format_ext) in published_formats:
- video_url = (video_base_url + format_abbr + '/'
- + base_name + format_ext)
- description += ("""<br/><a href='%s'>Video %s format</a>"""
- % (esc_attr(video_url),
- esc_content(format_abbr)))
- description += "</p>"
+def begin_pycon_upload(e, blipid, blipuser, blippass, eventname, description, filename2):
+ response = blip.Upload(blipid, blipuser, blippass, eventname, description, filename2)
+ print response
+ blipurl = re.search("post_url>(.*)</post" ,response).groups()[0]
+ print "Blip URL is: " + blipurl
+ eventname2 = eventname.replace("&", "and")
+ twitterpost.notify(eventname2, blipurl)
+ e.published_url = blipurl
+ e.published_time = datetime.datetime.now()
+# e.save()
+ return blipurl
- print >>rss, """\
-<item>
- <title>%s</title>
- <link>%s</link>
- <description>%s</description>
- <pubDate>%s</pubDate>
- <media:content url='%s' medium='video' isDefault='true' duration='%d'/>
- <guid>%s</guid>
-</item>""" % (esc_content(title),
- esc_content(video_url),
- esc_content(description),
- published_time.strftime(time_format),
- esc_attr(video_url), (end_time - start_time).seconds,
- esc_content(video_url))
+if __name__ == "__main__":
+ os.environ['DJANGO_SETTINGS_MODULE'] = 'pyconvideo.settings'
+ sys.path.append('/usr/share/debconf-video-store')
+ to_be_published()
- print >>rss, "</channel>"
- print >>rss, "</rss>"
-def publish(config, file_names):
- os.chdir(config['FILE_BASE'])
- os.spawnvp(os.P_WAIT, 'rsync',
- ['rsync', '--relative', '--partial', '--times', '-e ssh', '-vvv', '--bwlimit=307']
- + file_names
- + [config['PUBLICATION_PATH']])
-
-def main():
- cur = database.get_cursor()
-
- conference_title = config['CONFERENCE_NAME']
- cur.execute('SELECT conference_id FROM conference'
- ' WHERE title = %(title)s',
- {'title': conference_title})
- conference_id = cur.fetchone()
-
-
- cur.execute("""
-SELECT video_target_file.id, target_format_abbr, event_recording_base_name,
- filename_extension
-FROM
-(((video_target_file JOIN video_event_recording
- ON video_target_file.event_recording_id = video_event_recording.id)
- JOIN event
- ON video_event_recording.event_id = event.event_id)
- JOIN video_target_format
- ON video_target_file.target_format_id = video_target_format.id)
-WHERE event.conference_id = %(conference_id)s
- AND video_target_format.published
- AND published_time IS NULL
- ORDER BY video_bit_rate asc
-""",
- {'conference_id': conference_id})
- for file_id, format_abbr, base_name, format_ext in cur.fetchall():
- publish(config, ['%s/%s%s' % (format_abbr, base_name, format_ext)])
- cur.execute("""
-UPDATE video_target_file
-SET published_time = (CURRENT_TIMESTAMP AT TIME ZONE 'GMT')
-WHERE id = %(file_id)s
-""",
- {'file_id': file_id})
- make_rss(config, cur)
- publish(config, ['index.rss'])
- cur.execute("COMMIT")
-
-if __name__ == '__main__':
- main()
Modified: package/branches/pycon09/src/dc-video-schema.sql
===================================================================
--- package/branches/pycon09/src/dc-video-schema.sql 2009-04-01 09:01:06 UTC (rev 419)
+++ package/branches/pycon09/src/dc-video-schema.sql 2009-04-14 07:02:46 UTC (rev 420)
@@ -114,6 +114,7 @@
locked_by integer,
generated_time timestamp, -- in GMT
published_time timestamp, -- in GMT
+ published_url character varying(200),
UNIQUE (event_recording_id, target_format_id)
);
Modified: package/branches/pycon09/src/media/style.css
===================================================================
--- package/branches/pycon09/src/media/style.css 2009-04-01 09:01:06 UTC (rev 419)
+++ package/branches/pycon09/src/media/style.css 2009-04-14 07:02:46 UTC (rev 420)
@@ -29,12 +29,12 @@
background: #282942;
}
-#emphasis td {
+#emphasis tr td.{
padding: 0px 3px;
border-bottom: 1px solid black;
}
-#emphasis tr:hover td {
+#emphasis hover tr td.{
color: #D3D3DE;
background: #282942;
}
@@ -47,29 +47,48 @@
color: grey;
}
-tr.status-A {
+td.status-A {
background-color: #009900;
}
-tr.status-B {
+td.status-B {
background-color: #006600;
}
-tr.status-C {
+td.status-C {
background-color: #cc9900;
}
-tr.status-D {
+td.status-D {
background-color: black;
color: red;
}
-tr.status-F {
+td.status-F {
background-color: #ff0000;
color: white;
}
-tr.status-X {
- color: white;
+tr.status-A {
+ background-color: #009900;
}
+tr.status-B {
+ background-color: #006600;
+}
+
+tr.status-C {
+ background-color: #cc9900;
+}
+
+tr.status-D {
+ background-color: black;
+ color: red;
+}
+
+tr.status-F {
+ background-color: #ff0000;
+ color: white;
+}
+
+
Modified: package/branches/pycon09/src/pyconvideo/pyconvideo/admin.py
===================================================================
--- package/branches/pycon09/src/pyconvideo/pyconvideo/admin.py 2009-04-01 09:01:06 UTC (rev 419)
+++ package/branches/pycon09/src/pyconvideo/pyconvideo/admin.py 2009-04-14 07:02:46 UTC (rev 420)
@@ -19,7 +19,7 @@
class VideoTargetFileAdmin(admin.ModelAdmin):
fields = ['event', 'target_format',
'generated_time', 'file_status', 'comments', 'locked_by',
- 'published_time']
+ 'published_time', 'published_url']
list_display = ['target_filename', 'file_status', 'locked_by']
list_filter = ['target_format', 'file_status']
Modified: package/branches/pycon09/src/pyconvideo/pyconvideo/models.py
===================================================================
--- package/branches/pycon09/src/pyconvideo/pyconvideo/models.py 2009-04-01 09:01:06 UTC (rev 419)
+++ package/branches/pycon09/src/pyconvideo/pyconvideo/models.py 2009-04-14 07:02:46 UTC (rev 420)
@@ -148,6 +148,7 @@
blank=True, null=True)
generated_time = models.DateTimeField()
published_time = models.DateTimeField()
+ published_url = models.CharField(max_length=200)
def _target_filename(self):
return debconfvideo.target_filename(self.event,
self.target_format)
Modified: package/branches/pycon09/src/pyconvideo/pyconvideo/videotargetfile_list.html
===================================================================
--- package/branches/pycon09/src/pyconvideo/pyconvideo/videotargetfile_list.html 2009-04-01 09:01:06 UTC (rev 419)
+++ package/branches/pycon09/src/pyconvideo/pyconvideo/videotargetfile_list.html 2009-04-14 07:02:46 UTC (rev 420)
@@ -46,6 +46,11 @@
{% for target in file_set.target %}
{% if target %}
<td class="status-{{ target.file_status.file_status_code }}">
+ {% if target.published_time %}
+ <B>PUBLISHED: </B>{{ target.comments }}<br>
+ {{ target.published_time }}<br>
+ <a href="{{ target.published_url}}">{{ target.published_url}}</a>
+ {% else %}
{% if target.locked_by %}
{% ifequal target.locked_by user %}
<form action="/target/{{ target.id }}/review" method="post">
@@ -57,6 +62,7 @@
<input type="submit" name="submit" value="Review" />
</form>
{% endif %}
+ {% endif %}
</td>
{% else %}
<td>pending</td>
More information about the Debconf-video-commits
mailing list