You are here: Home / Documentation / How To's / Scripts to find Kaltura videos on a site

Scripts to find Kaltura videos on a site

by nguyen — published Feb 01, 2014 10:50 AM, last modified Aug 16, 2016 10:50 AM

On one particular Plone site

If you want to find the Kaltura videos just on one site, add this Script (Python) to your portal_skins/custom folder:

.findKaltura

numfound = 0
results = context.portal_catalog()
print "<p>Found the following Kaltura videos on this site:</p>"

print "<ul>"

for brain in results:
    object = brain.getObject()
    if hasattr(object, "getText"):
        text = object.getText()
        if text.find('kaltura_player') != -1:
		    t = brain["Title"]
		    url = brain.getURL()
		    print "<li><a href='%s'>%s</a></li>" % (url, t)
		    numfound+=1

print "</ul>"
print "<p>Found %s videos</p>" % numfound
print "<p>Searched %s objects</p>" % len(results)
print "Search complete."
return printed

For all sites in a Zope

If you want to find all the Kaltura videos in all the Plone sites in a Zope, add these Script (Python) objects to the root of the Zope: 

.findKaltura2

urls = []
results = context.portal_catalog()
for brain in results:
    try:
      object = brain.getObject()
      if hasattr(object, "getText"):
          text = object.getText()
          if text.find('kaltura_player') != -1:
        	url = brain.getURL()
        	urls.append(url)
    except:
      pass
if len(urls) == 0:
	return "None"
else:
	return "".join(["<li>"+"<a href='"+u+"'>"+u+"</a>"+"</li>" for u in urls])

and 

.listSitesWithKalturaVideos

print "<ul>"
for itemTuple in context.items():
  (id, itemType) = itemTuple
  item = context[id]
  if item.meta_type == "Folder":
    for tuple2 in item.items():
      (id2, itemType2) = tuple2
      item2 = item[id2]
      if item2.meta_type == "Plone Site":
        print "<li>"
        print '<a href="%s">%s</a>' % (item2.absolute_url()+"/.findKaltura2", item2.id)
        print "</li>"
  elif item.meta_type == "Plone Site":
        print "<li>"
        print '<a href="%s">%s</a>' % (item.absolute_url()+"/.findKaltura2", item.id)
        print "</li>"
print "</ul>"
print "<p>Done</p>"
return printed

When you run the .listSitesWithKalturaVideos you'll be given a list of links to click on. Open each one in a background window; each window will show you a list of all the videos in that site.

Navigation