fix migration script for subdomains; small fixes

This commit is contained in:
Sanj 2012-02-15 18:02:38 +05:30
parent 294fe654a8
commit eadcb07279
2 changed files with 13 additions and 8 deletions

View File

@ -5,14 +5,17 @@ from texts.models import *
NEXT = "http://next.pad.ma/"
OLD = "http://pad.ma/"
IdMapping = {}
regex = re.compile(r'(http:\/\/.*?pad.ma\/(V.*?))[\s\"\<\n]')
regex2 = re.compile(r'(http:\/\/.*?pad.ma\/(V.*?))$')
def getNewUrl(oldUrl):
new = oldUrl.replace(OLD, NEXT)
new = re.sub(regex2, lambda pat: NEXT + pat.groups()[1], oldUrl)
# print new
# new = oldUrl.replace(OLD, NEXT)
try:
return urllib2.urlopen(new).url
except:
print "ERROR: " + oldUrl
return None
def getNewId(oldId):
oldId = oldId.group().replace(OLD, "")[:-1]
@ -26,11 +29,13 @@ def getNewId(oldId):
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)
newUrl = getNewUrl(f[0])
if newUrl is None:
continue
# print newUrl
text = text.replace(f[0], newUrl)
return text
# for m in re.findall(regex, text):
# print getNewId(m)

View File

@ -196,7 +196,7 @@ function setupPadmaLink(videoObj, data) {
var thisTrack = tracks[t];
var thisTrackLayers = filterLayersByTracks(currentLayers, [thisTrack]);
if (thisTrackLayers.length > 0) {
annotHtml += '<span class="padmaTrack">' + thisTrack + "s:</span><br />";
annotHtml += '<span class="padmaTrack">' + thisTrack + ":</span><br />";
}
for (var i=0; i < thisTrackLayers.length; i++) {
var thisTrack = thisTrackLayers[i];