[xiph-commits] r18862 - in branches/dir.xiph.org: . cronjobs inc templates

dm8tbr at svn.xiph.org dm8tbr at svn.xiph.org
Thu Mar 7 06:51:32 PST 2013


Author: dm8tbr
Date: 2013-03-07 06:51:32 -0800 (Thu, 07 Mar 2013)
New Revision: 18862

Added:
   branches/dir.xiph.org/xml/
   branches/dir.xiph.org/yp.xml
Modified:
   branches/dir.xiph.org/cronjobs/generate_top.php
   branches/dir.xiph.org/cronjobs/generate_xml.php
   branches/dir.xiph.org/cronjobs/update_stats.php
   branches/dir.xiph.org/inc/lib.dir.php
   branches/dir.xiph.org/index.php
   branches/dir.xiph.org/templates/menu_right.tpl
Log:
Adding Opus and WebM support to dir.xiph.org web interface code along with minor other improvements.


Modified: branches/dir.xiph.org/cronjobs/generate_top.php
===================================================================
--- branches/dir.xiph.org/cronjobs/generate_top.php	2013-03-02 23:01:28 UTC (rev 18861)
+++ branches/dir.xiph.org/cronjobs/generate_top.php	2013-03-07 14:51:32 UTC (rev 18862)
@@ -12,26 +12,51 @@
 // You need at least that many listeners to make it to the homepage. SQL "optimization"
 // that allows to lower the number of rows to sort on. Should be set correctly, or the
 // CPU will burn.
-define('MIN_LISTENERS_FOR_HOMEPAGE', 10);
+//define('MIN_LISTENERS_FOR_HOMEPAGE', 10);
 // How many streams will appear on the homepage
-define('MAX_STREAMS_ON_HOMEPAGE', 20);
+//define('MAX_STREAMS_ON_HOMEPAGE', 20);
+// How many Opus streams appear
+define('ID_OPUS', '107' );
+define('MAX_STREAMS_OPUS', 3 );
+// How many good codec streams appear
+define('ID_GOOD', '101, 102, 108');
+define('MAX_STREAMS_GOOD', 15 );
+// How many bad codec streams appear
+define('ID_BAD', '103, 104, 105, 106, 100'); // 100 is 'unknown' and likely ogg... need to check
+define('MAX_STREAMS_BAD', 5 );
 
 try
 {
 //    $query = 'SELECT `id` FROM `mountpoint` ORDER BY `listeners` DESC LIMIT %d;';
-    $query = 'SELECT m.`id`, SUM(s.`checked`) / COUNT(*) AS `checked` '
+    $query = 'SELECT m.`id`, SUM(s.`checked`) / COUNT(*) AS `checked`'
             .'FROM `mountpoint` AS m INNER JOIN `server` AS s ON m.`id` = s.`mountpoint_id` '
+            .'WHERE m.`media_type_id` IN (%s) AND s.`listeners` > 0 '
             .'GROUP BY m.`id` '
-            .'HAVING `checked` = 1 ORDER BY m.`listeners` DESC LIMIT %d;';
+            .'HAVING `checked` = 1 '
+            .'ORDER BY RAND() LIMIT %d;';
 //    $query = 'SELECT `id` FROM `mountpoint` ORDER BY RAND() LIMIT %d;';
-    $query = sprintf($query, MAX_STREAMS_ON_HOMEPAGE);
-    $data = $db->selectQuery($query);
+    $query_opus = sprintf($query, ID_OPUS ,MAX_STREAMS_OPUS);
+    $data_opus = $db->selectQuery($query_opus);
+    $query_good = sprintf($query, ID_GOOD, MAX_STREAMS_GOOD);
+    $data_good = $db->selectQuery($query_good);
+    $query_bad = sprintf($query, ID_BAD, MAX_STREAMS_BAD);
+    $data_bad = $db->selectQuery($query_bad);
 	$res = array();
-	while (!$data->endOf())
+	while (!$data_opus->endOf())
 	{
-		$res[] = intval($data->current('id'));
-		$data->next();
+		$res[] = intval($data_opus->current('id'));
+		$data_opus->next();
 	}
+	while (!$data_good->endOf())
+	{
+		$res[] = intval($data_good->current('id'));
+		$data_good->next();
+	}
+	while (!$data_bad->endOf())
+	{
+		$res[] = intval($data_bad->current('id'));
+		$data_bad->next();
+	}
 	$data = $res;
 }
 catch (SQLNoResultException $e)

Modified: branches/dir.xiph.org/cronjobs/generate_xml.php
===================================================================
--- branches/dir.xiph.org/cronjobs/generate_xml.php	2013-03-02 23:01:28 UTC (rev 18861)
+++ branches/dir.xiph.org/cronjobs/generate_xml.php	2013-03-07 14:51:32 UTC (rev 18862)
@@ -5,7 +5,7 @@
 
 ini_set('memory_limit', '128M');
 
-define('XML_OUTPUT', dirname(__FILE__).'/../yp.xml');
+define('XML_OUTPUT', dirname(__FILE__).'/../xml/yp.xml');
 
 // Database connection
 $db = DirXiphOrgDBC::getInstance();

Modified: branches/dir.xiph.org/cronjobs/update_stats.php
===================================================================
--- branches/dir.xiph.org/cronjobs/update_stats.php	2013-03-02 23:01:28 UTC (rev 18861)
+++ branches/dir.xiph.org/cronjobs/update_stats.php	2013-03-07 14:51:32 UTC (rev 18862)
@@ -19,6 +19,20 @@
 $count = $db->singleQuery($query)->current('count');
 $memcache->set(ENVIRONMENT.'_servers_'.CONTENT_TYPE_MP3, $count, false, 600); // 10 minutes
 
+// Opus
+$where = array();
+$where = sprintf($where_pattern, CONTENT_TYPE_OPUS);
+$query = sprintf($query_pattern, $where);
+$count = $db->singleQuery($query)->current('count');
+$memcache->set(ENVIRONMENT.'_servers_'.CONTENT_TYPE_OPUS, $count, false, 600); // 10 minutes
+
+// WebM
+$where = array();
+$where = sprintf($where_pattern, CONTENT_TYPE_WEBM);
+$query = sprintf($query_pattern, $where);
+$count = $db->singleQuery($query)->current('count');
+$memcache->set(ENVIRONMENT.'_servers_'.CONTENT_TYPE_WEBM, $count, false, 600); // 10 minutes
+
 // Vorbis
 $where = array();
 $where = sprintf($where_pattern, CONTENT_TYPE_OGG_VORBIS);

Modified: branches/dir.xiph.org/inc/lib.dir.php
===================================================================
--- branches/dir.xiph.org/inc/lib.dir.php	2013-03-02 23:01:28 UTC (rev 18861)
+++ branches/dir.xiph.org/inc/lib.dir.php	2013-03-07 14:51:32 UTC (rev 18862)
@@ -28,7 +28,17 @@
 	{
 		return CONTENT_TYPE_OGG_THEORA;
 	}
+	elseif ($content_type == "application/ogg+opus")
+	{
+		return CONTENT_TYPE_OPUS;
+	}
 	
+	// WebM
+	if ($content_type == "video/webm" || $content_type == "audio/webm" )
+        {
+                return CONTENT_TYPE_WEBM;
+        }
+
 	// MP3
 	elseif ($content_type == "audio/mpeg" || $content_type == "audio/x-mpeg" || $content_type == 'application/mp3')
 	{
@@ -72,6 +82,12 @@
 		case CONTENT_TYPE_OGG_THEORA:
 			$type = 'Ogg Theora';
 			break;
+                case CONTENT_TYPE_OPUS:
+                        $type = 'Opus';
+                        break;
+                case CONTENT_TYPE_WEBM:
+                        $type = 'WebM';
+                        break;
 		case CONTENT_TYPE_MP3:
 			$type = 'MP3';
 			break;
@@ -106,6 +122,12 @@
                 case CONTENT_TYPE_OGG_THEORA:
                         $type = 'Ogg_Theora';
                         break;
+                case CONTENT_TYPE_OPUS:
+                        $type = 'Opus';
+                        break;
+                case CONTENT_TYPE_WEBM:
+                        $type = 'WebM';
+                        break;
                 case CONTENT_TYPE_MP3:
                         $type = 'MP3';
                         break;
@@ -151,6 +173,16 @@
 			    $type .= '+theora';
 			}
 			break;
+                case CONTENT_TYPE_OPUS:
+                        $type = 'application/ogg';
+			if ($full_type)
+			{
+			    $type .= '+opus';
+			}
+                        break;
+                case CONTENT_TYPE_WEBM:
+                        $type = 'video/webm';
+                        break;
 		case CONTENT_TYPE_MP3:
 			$type = 'audio/mpeg';
 			break;

Modified: branches/dir.xiph.org/index.php
===================================================================
--- branches/dir.xiph.org/index.php	2013-03-02 23:01:28 UTC (rev 18861)
+++ branches/dir.xiph.org/index.php	2013-03-07 14:51:32 UTC (rev 18862)
@@ -18,6 +18,8 @@
 $tpl->assign('servers_total', $memcache->get(ENVIRONMENT.'_servers_total'));
 $tpl->assign('servers_mp3', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_MP3));
 $tpl->assign('servers_vorbis', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_OGG_VORBIS));
+$tpl->assign('servers_opus', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_OPUS));
+$tpl->assign('servers_webm', $memcache->get(ENVIRONMENT.'_servers_'.CONTENT_TYPE_WEBM));
 $tpl->display('index.tpl');
 
 // Footer

Modified: branches/dir.xiph.org/templates/menu_right.tpl
===================================================================
--- branches/dir.xiph.org/templates/menu_right.tpl	2013-03-02 23:01:28 UTC (rev 18861)
+++ branches/dir.xiph.org/templates/menu_right.tpl	2013-03-07 14:51:32 UTC (rev 18862)
@@ -8,6 +8,15 @@
 {if !empty($servers_vorbis)}
 							<li>Ogg Vorbis: <strong>{$servers_vorbis|intval}</strong></li>
 {/if}
+{if !empty($servers_opus)}
+							<li>Opus: <strong>{$servers_opus|intval}</strong></li>
+{/if}
+{if !empty($servers_webm)}
+							<li>WebM: <strong>{$servers_webm|intval}</strong></li>
+{/if}
+{if !empty($servers_theora)}
+							<li>Theora: <strong>{$servers_theora|intval}</strong></li>
+{/if}
 {if !empty($servers_mp3)}
 							<li>MP3: <strong>{$servers_mp3|intval}</strong></li>
 {/if}
@@ -55,10 +64,12 @@
 						<h3>By format</h3>
 						<div id="search-format">
 							<ul>
+								<li><a href="{$root_url}/by_format/Opus">Opus</a></li>
 								<li><a href="{$root_url}/by_format/Ogg_Vorbis">Ogg Vorbis</a></li>
 								<li><a href="{$root_url}/by_format/MP3">MP3</a></li>
 								<li><a href="{$root_url}/by_format/AAC">AAC</a></li>
 								<li><a href="{$root_url}/by_format/AAC+">AAC+</a></li>
+								<li><a href="{$root_url}/by_format/WebM">WebM</a></li>
 								<li><a href="{$root_url}/by_format/Ogg_Theora">Ogg Theora</a></li>
 								<li><a href="{$root_url}/by_format/NSV">NSV</a></li>
 							</ul>

Added: branches/dir.xiph.org/yp.xml
===================================================================
--- branches/dir.xiph.org/yp.xml	                        (rev 0)
+++ branches/dir.xiph.org/yp.xml	2013-03-07 14:51:32 UTC (rev 18862)
@@ -0,0 +1 @@
+link /var/www/dir.xiph.org/xml/yp.xml
\ No newline at end of file


Property changes on: branches/dir.xiph.org/yp.xml
___________________________________________________________________
Added: svn:special
   + *



More information about the commits mailing list