allfiles =re.findall(imgfile_exp, gallery)
print 'ALLFILES', allfiles
for imgfile in allfiles:
imgfile = imgfile[1]
#imgsrc = imgfile
imgsrc = api_file_url(imgfile) # seaarch for original image
newimg = ''
gallery_imgs.append(imgsrc)
print 'GALLERY_IMGS', gallery_imgs
ungallery_imgs = " ".join(gallery_imgs)
print 'ungallery_imgs', ungallery_imgs
content = re.sub(gallery_exp, ungallery_imgs, content)
print 'images content', content
## BUG: Images are being replaced as
# EG: File:Mb-WordNet-tour-version2-08.png File:Labanotation1.jpg
return content
def replace_video(content):
videos = []
videos_found = re.findall(video_exp, content)
for video in videos_found:
video_provider = str(video[0])
video_hash = str(video[1])
video_src = None
if (video_provider.lower()) == 'youtube':
video_src="https://www.youtube.com/embed/" + video_hash
elif (video_provider.lower()) == 'vimeo':
video_src="https://player.vimeo.com/video/" + video_hash
if video_src:
videos.append(video_src)
iframe = "".format(video_src)
content = re.sub(video_exp, iframe, content)
else:
content = re.sub(video_exp, '', content)
return content
## Video Replacement: problem with video: iframe is placed inside . It shouldn't
## replace gallery - not yet there