-
Notifications
You must be signed in to change notification settings - Fork 2
/
feed-trebuchet-leaf.php
89 lines (78 loc) · 3.08 KB
/
feed-trebuchet-leaf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
#ini_set('error_repor#ting', E_ALL);
#ini_set('display_errors', 'On');
#ini_set('display_startup_errors', 'On');
/**
* Trebuchet Leaf Feed Template.
*
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$args = array('post_type' => 'woo_video', 'numberposts' => 9999999999);
$posts = get_posts( $args);
# function to convert the time format we're supplying to seconds
function timeToSeconds($time) {
$parts = explode(':', $time);
$seconds = 0;
foreach ($parts as $i => $val) {
$seconds += $val * pow(60, 2 - $i);
}
return round($seconds);
}
$post_order_count = 0;
$default_rating = 'PG';
# Sony, Air, Business, Climate Change, Living, Nature, People, Transport, Technology, Water, Ashden, Featured
$included_categories = Array(512, 82, 3, 11, 20, 55, 33, 42, 49, 80, 275, 515, 529);
echo '<?xml version="1.0" encoding="UTF-8" ?>'; ?>
<trebuchet version="2.0">
<mehta_data_version>1</mehta_data_version>
<assets>
<?php foreach($posts as $post) {
$categories = get_the_terms( $post->ID, 'woo_video_category');
$cats = array();
foreach( $categories as $category ) {
if (in_array($category->term_id, $included_categories)) {
array_push($cats, $category->term_id);
}
}
$in_cats_count = count($cats);
if ((get_post_meta($post->ID, 'trebuchet_enabled', true) == 'true') && ($in_cats_count > 0)) {
?>
<asset id="<?php echo $post->ID; ?>">
<?php
$post_order = get_post_meta($post->ID, 'trebuchet_order', true);
if ($post_order == '') {
$post_order_count++;
$post_order = $post_order_count;
}
foreach ( $cats as $cat ) {
echo '<in_category id="'.$cat.'" order="'.$post_order.'" />';
} ?>
<type>video</type>
<default_icons>
<icon_std><?php
$asset_path = get_post_meta($post->ID, 'asset_path', true);
$base_dir = basename($asset_path);
echo 'http://static.green.tv/static/videos/'.$base_dir.'/'.$base_dir.'.jpg';
?></icon_std>
</default_icons>
<languages>
<language id="en">
<title><?php echo the_title_rss(); ?></title>
<description><![CDATA[<?php echo the_excerpt_rss(); ?>]]></description>
</language>
</languages>
<asset_url downloadable='false'><?php echo 'http://static.green.tv/static/videos/'.$base_dir.'/'.get_post_meta($post->ID, 'mp4_asset_filename', true); ?></asset_url>
<rating scheme="urn:mpaa"><?php
$rating = get_post_meta($post->ID, 'trebuchet_rating', true);
if ($rating == '') {
$rating = $default_rating;
}
echo $rating;
?></rating>
<duration><?php echo timeToSeconds(get_post_meta($post->ID, 'mp4_asset_duration', true)); ?></duration>
</asset>
<?php }
} ?>
</assets>
</trebuchet>