mirror of
https://github.com/dyne/FreeJ.git
synced 2026-06-16 12:59:33 +02:00
Adding new scripts. An example python script playing video, and a python script which parses RSS2 feeds and
produces JavaScript for playing the videos from the "enclosures" in the feed. layer.cpp - small check to avoid a segmentation fault on a null pointer.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#/usr/bin/python2.5
|
||||
# andy@engagemedia.org
|
||||
#generate a FreeJ javascript file, using a RSS2 feed
|
||||
|
||||
from elementtree import ElementTree as et
|
||||
from Cheetah.Template import Template
|
||||
import urllib
|
||||
import os
|
||||
import shutil
|
||||
|
||||
RSS_FILE="http://www.engagemedia.org/featured-videos/RSS2"
|
||||
JAVASCRIPT_TEMPLATE="plumi_template.js"
|
||||
JAVASCRIPT_FILE="plumi.js"
|
||||
|
||||
#download latest RSS2
|
||||
print "fetching %s " % RSS_FILE
|
||||
feed = urllib.urlopen(RSS_FILE)
|
||||
print "parsing %s " % RSS_FILE
|
||||
parsed_feed = et.parse(feed)
|
||||
|
||||
#setup the parameters from channel
|
||||
print "making js file %s " % JAVASCRIPT_FILE
|
||||
data_map = {}
|
||||
|
||||
#download image, and remember path
|
||||
image_url = parsed_feed.find('channel').find('image').find('url').text
|
||||
#get the image
|
||||
print "fetching image logo %s " % image_url
|
||||
downloaded_image=urllib.urlretrieve(image_url)
|
||||
#save it somewhere sensible.
|
||||
image_name=os.path.basename(image_url)
|
||||
shutil.copyfile(downloaded_image[0],image_name)
|
||||
#the abs file path
|
||||
image_file_path=os.path.abspath(image_name)
|
||||
|
||||
data_map['image_file_path'] = image_file_path
|
||||
|
||||
|
||||
data_map['channel_title'] = parsed_feed.find('channel').find('title').text
|
||||
data_map['videos'] = []
|
||||
|
||||
for video_elem in parsed_feed.getiterator('enclosure'):
|
||||
video_to_play = video_elem.get('url')
|
||||
js_var_name = "video_%s" % (len(data_map['videos']))
|
||||
video_dict = {'url':video_to_play, 'js_var_name':js_var_name}
|
||||
data_map['videos'].append(video_dict)
|
||||
|
||||
#write the new javascript file.
|
||||
t = Template(file=JAVASCRIPT_TEMPLATE, searchList=[data_map])
|
||||
f=open(JAVASCRIPT_FILE, 'w')
|
||||
f.write(t.respond())
|
||||
f.close()
|
||||
@@ -0,0 +1,44 @@
|
||||
// andy@engagemedia.org
|
||||
// templated example script for using FreeJ and Plumi (plone video CMS)
|
||||
//
|
||||
|
||||
header_text = new TextLayer();
|
||||
header_text.start();
|
||||
add_layer(header_text);
|
||||
header_text.set_position(70,0);
|
||||
header_text.size(50);
|
||||
header_text.color(255,0,0);
|
||||
header_text.print("$channel_title")
|
||||
//header_text.set_fps(25);
|
||||
|
||||
logo_image = new ImageLayer();
|
||||
logo_image.open("$image_file_path")
|
||||
logo_image.activate(true);
|
||||
logo_image.start()
|
||||
logo_image.set_position(0,0);
|
||||
add_layer(logo_image);
|
||||
|
||||
#for $video in $videos
|
||||
|
||||
$video.js_var_name = new MovieLayer("$video.url")
|
||||
add_layer($video.js_var_name);
|
||||
|
||||
${video.js_var_name}.set_position(50,70);
|
||||
${video.js_var_name}.activate(true);
|
||||
|
||||
#end for
|
||||
|
||||
// START streaming
|
||||
|
||||
encoder = new VideoEncoder(10, 64000, 5, 24000);
|
||||
encoder.stream_host("giss.tv");
|
||||
encoder.stream_port(8000);
|
||||
encoder.stream_title("$channel_title")
|
||||
encoder.stream_username("source");
|
||||
encoder.stream_password("2t645");
|
||||
encoder.stream_mountpoint("freej-test.ogg");
|
||||
register_encoder(encoder);
|
||||
encoder.start_stream();
|
||||
|
||||
//END streaming
|
||||
|
||||
Reference in New Issue
Block a user