From a193d18d96f6562abac4b9da6112cedde0c02933 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 30 Jan 2014 20:16:05 -0800 Subject: Updating Videos and Script. Video numbers may now be decimals (i.e. 5.1, 5.2). If the number is 0 it is not displayed on the website. Updating the videos-from-csv.py script to distinguish between user facing video numbers and video ids. Also updating urls for many videos. --- devfiles/scripts/videos-from-csv.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'devfiles/scripts/videos-from-csv.py') diff --git a/devfiles/scripts/videos-from-csv.py b/devfiles/scripts/videos-from-csv.py index c1899b7..e9718d8 100755 --- a/devfiles/scripts/videos-from-csv.py +++ b/devfiles/scripts/videos-from-csv.py @@ -9,7 +9,18 @@ from string import Template #BASE_URL="http://foursquaregrow.s3-website-us-east-1.amazonaws.com/" BASE_URL="http://d12xq7pqelpwt.cloudfront.net/" -def mkjson(chapter, number, title, length, image, pdf, videos): +""" +Create the json file for a particular video. The fields are: + chapter: The chapter (i.e. Seeker, Believer, etc) + videoNumber: The number of the video in the chapter, starting with 1 + number: The video number to display to the user. 0 to hide number. + title: The video title. + length: The video length in seconds. + image: The url of the image to display. + pdf: The url of the outline pdf. + videos: A dictionary of mime type to video urls +""" +def mkjson(chapter, videoNumber, number, title, length, image, pdf, videos): vtemplate = Template("""{ "id": "$id", "number": "$number", @@ -30,9 +41,9 @@ def mkjson(chapter, number, title, length, image, pdf, videos): pass else: raise - filename = string.lower(directory + "/" + chapter + "-" + number + ".json") + filename = string.lower(directory + "/" + chapter + "-" + str(videoNumber) + ".json") with open(filename, 'w') as outfile: - outfile.write(vtemplate.substitute(dict(id=string.lower(chapter+"-"+number), + outfile.write(vtemplate.substitute(dict(id=string.lower(chapter+"-"+str(videoNumber)), chapter=chapter, number=number, title=title, length=length, image=BASE_URL + urllib.quote(image), pdf=BASE_URL + urllib.quote(pdf)))) @@ -47,6 +58,8 @@ def mkjson(chapter, number, title, length, image, pdf, videos): filename = sys.argv[1]; with open(filename, 'rb') as csvfile: + videoNumbers = dict() + reader = csv.reader(csvfile) for row in reader: chapter = row[0] @@ -58,7 +71,15 @@ with open(filename, 'rb') as csvfile: h264 = row[6] webm = row[7] + # Number the videos in the chapter starting with 1 + videoNumber = 1 + if chapter in videoNumbers: + videoNumber = videoNumbers[chapter] + + # Update the number for the next video + videoNumbers[chapter] = videoNumber + 1 + videos = { "video/mp4": h264, "video/webm": webm } - mkjson(chapter, number, title, length, image, pdf, videos) + mkjson(chapter, videoNumber, number, title, length, image, pdf, videos) -- cgit v1.2.3