fix migration script for subdomains; small fixes
This commit is contained in:
parent
294fe654a8
commit
eadcb07279
|
@ -5,14 +5,17 @@ from texts.models import *
|
||||||
NEXT = "http://next.pad.ma/"
|
NEXT = "http://next.pad.ma/"
|
||||||
OLD = "http://pad.ma/"
|
OLD = "http://pad.ma/"
|
||||||
IdMapping = {}
|
IdMapping = {}
|
||||||
|
regex = re.compile(r'(http:\/\/.*?pad.ma\/(V.*?))[\s\"\<\n]')
|
||||||
|
regex2 = re.compile(r'(http:\/\/.*?pad.ma\/(V.*?))$')
|
||||||
def getNewUrl(oldUrl):
|
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:
|
try:
|
||||||
return urllib2.urlopen(new).url
|
return urllib2.urlopen(new).url
|
||||||
except:
|
except:
|
||||||
print "ERROR: " + oldUrl
|
print "ERROR: " + oldUrl
|
||||||
|
return None
|
||||||
|
|
||||||
def getNewId(oldId):
|
def getNewId(oldId):
|
||||||
oldId = oldId.group().replace(OLD, "")[:-1]
|
oldId = oldId.group().replace(OLD, "")[:-1]
|
||||||
|
@ -26,11 +29,13 @@ def getNewId(oldId):
|
||||||
return newId
|
return newId
|
||||||
|
|
||||||
def replaceUrls(text):
|
def replaceUrls(text):
|
||||||
regex = re.compile(r'(http:\/\/pad.ma\/V.*?)[\s\"\<]')
|
|
||||||
for f in re.findall(regex, text):
|
for f in re.findall(regex, text):
|
||||||
newUrl = getNewUrl(f)
|
newUrl = getNewUrl(f[0])
|
||||||
print newUrl
|
if newUrl is None:
|
||||||
text = text.replace(f, newUrl)
|
continue
|
||||||
|
# print newUrl
|
||||||
|
text = text.replace(f[0], newUrl)
|
||||||
return text
|
return text
|
||||||
# for m in re.findall(regex, text):
|
# for m in re.findall(regex, text):
|
||||||
# print getNewId(m)
|
# print getNewId(m)
|
||||||
|
|
|
@ -196,7 +196,7 @@ function setupPadmaLink(videoObj, data) {
|
||||||
var thisTrack = tracks[t];
|
var thisTrack = tracks[t];
|
||||||
var thisTrackLayers = filterLayersByTracks(currentLayers, [thisTrack]);
|
var thisTrackLayers = filterLayersByTracks(currentLayers, [thisTrack]);
|
||||||
if (thisTrackLayers.length > 0) {
|
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++) {
|
for (var i=0; i < thisTrackLayers.length; i++) {
|
||||||
var thisTrack = thisTrackLayers[i];
|
var thisTrack = thisTrackLayers[i];
|
||||||
|
|
Loading…
Reference in New Issue
Block a user