migration to next.pad.ma

This commit is contained in:
Sanj 2012-02-15 15:05:06 +05:30
parent 8457876101
commit 294fe654a8
4 changed files with 55 additions and 3 deletions

View File

View File

@ -0,0 +1,44 @@
import urllib2
import re
from texts.models import *
NEXT = "http://next.pad.ma/"
OLD = "http://pad.ma/"
IdMapping = {}
def getNewUrl(oldUrl):
new = oldUrl.replace(OLD, NEXT)
try:
return urllib2.urlopen(new).url
except:
print "ERROR: " + oldUrl
def getNewId(oldId):
oldId = oldId.group().replace(OLD, "")[:-1]
print oldId
if oldId in IdMapping:
return IdMapping[oldId]
url = NEXT + oldId
u = urllib2.urlopen(url)
newId = u.url.replace(NEXT, "")
IdMapping[oldId] = newId
return newId
def replaceUrls(text):
regex = re.compile(r'(http:\/\/pad.ma\/V.*?)[\s\"\<]')
for f in re.findall(regex, text):
newUrl = getNewUrl(f)
print newUrl
text = text.replace(f, newUrl)
return text
# for m in re.findall(regex, text):
# print getNewId(m)
def doAll():
for p in PadmaText.objects.all():
print p.title
newText = replaceUrls(p.html)
p.html = newText
p.save()

View File

@ -13,21 +13,29 @@ $(function() {
$(window).resize(resize); $(window).resize(resize);
}); });
function setupPadmaLink(videoObj, data) { function setupPadmaLink(videoObj, data) {
var $a = $(data.jq); var $a = $(data.jq);
// $a.data("isDisplayed", false); // $a.data("isDisplayed", false);
//FIXME: tc is WRONG!!! //FIXME: tc is WRONG!!!
if (!$.inArray(data.linkData.type, ["info", "editor", "tc", "tcRange", "layer"])) { // if (!$.inArray(data.linkData.type, ["info", "editor", "tc", "tcRange", "layer"])) {
// return false;
// }
if ($.inArray(data.linkData.type, ["tcRange", 'info']) == -1) {
return false; return false;
} }
console.log(videoObj);
// console.log(data.linkData); // console.log(data.linkData);
//FIXME: this whole thing is a bit of rubbish, and they should not set type = 'tcRange' //FIXME: this whole thing is a bit of rubbish, and they should not set type = 'tcRange'
if (data.linkData.type == 'info' || data.linkData.type == 'editor' || data.linkData.type == "tc") { if (data.linkData.type == 'info' || data.linkData.type == 'editor' || data.linkData.type == "tc") {
data.linkData.tcIn = ms2npt(0); data.linkData.tcIn = ms2npt(0);
data.linkData.tcOut = ms2npt(videoObj.video.duration); data.linkData.tcOut = ms2npt(videoObj.video.duration * 1000);
data.linkData.type = "tcRange"; data.linkData.type = "tcRange";
} }

View File

@ -91,7 +91,7 @@ $(function() {
<a title="Right-click and Save Link As to download video" target="_blank" href="<%= video.getDownloadLink(linkData.tcIn, linkData.tcOut) %>">&darr;</a> <a title="Right-click and Save Link As to download video" target="_blank" href="<%= video.getDownloadLink(linkData.tcIn, linkData.tcOut) %>">&darr;</a>
</span> </span>
</div> </div>
<video src="<%= video.video.urls['320'] %>" width="320" poster="<%= video.getFrame(linkData.tcIn) %>" controls="controls"></video> <video src="<%= video.getVideo(0, '240') %>" width="320" poster="<%= video.getFrame(linkData.tcIn) %>" controls="controls"></video>
<div class="annotationWrapper"> <div class="annotationWrapper">
<div class="annotationText"> <div class="annotationText">