CVS edit link for yohnson

This is a new version of the abandoned Shoutcast module that will work with D6 and the current version of the Shoutcast Server 1.9.8

The module was originally developed from the skeleton of the Weather Underground module and has been discussed in the Radio group where additional features were requested and implemented.

CommentFileSizeAuthor
#8 shoutcast.zip3.33 KByohnson
#2 shoutcast.zip3.99 KByohnson

Comments

sun’s picture

yohnson’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new3.99 KB

This is the initial upload of the Shoutcast module which will obtain statistics from a working installation of Shoutcast 1.9.8v Server, it does not perform the same function as the D5 module which is no longer maintained. http://drupal.org/project/shoutcast

The main difference is the antiquated module will configure the Shoutcast server running on the same computer as Drupal. This module is meant to only acquire statistics from a working installation which may be remote to the website

The module produces a block displaying the statistics and will be maintained for D6 and D7(once officially released) Its my 1st module created and would appreciate any pointers to make it better.

avpaderno’s picture

Issue tags: +Module review
sun’s picture

Status: Needs review » Needs work
; Information added by drupal.org packaging script on 2009-01-29
version = "6.x-2.0"
core = "6.x"
project = "shoutcast"
datestamp = "1233267944"

This information is added by the d.o packaging script and should not be contained in the original .info file.

} // function shoutcast_help

(minor) In general, we don't do this for Drupal code.

     $block[0]["info"] = t('Shoutcast!!');

(minor) Less emotion? ;)

     $xml_cache = cache_get('shoutcast');

if ((!$xml_cache) || ($xml_cache->expire < time())) {
 
error_reporting (E_ALL ^ E_NOTICE);
$host = variable_get('shoutcast_ip', '127.0.0.1');
$port = variable_get('shoutcast_port', '8000');
$password = variable_get('shoutcast_pw', 'password');
   $username ='admin';
   $useragent=variable_get('shoutcast_useragent','Mozilla/5.001 (drupal Shoutcast Stats Module)');
   $timeout=variable_get('shoutcast_timeout','30');
$ch;$xml;

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options

curl_setopt($ch, CURLOPT_URL, "http://$host:$port/admin.cgi?mode=viewxml");
curl_setopt($ch, CURLOPT_USERAGENT, $useragent); 
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 

$xml=curl_exec($ch);
if($xml === FALSE || variable_get('shoutcast_error_handling',1)===1 ) {
$err=curl_error($ch);
$errnum=curl_errno($ch);

watchdog('shoutcast','Curl Said: %error -- Error Number: %errnum *Use Operations Link for more details on result code', array('%error'=>$err,'%errnum'=>$errnum) ,WATCHDOG_ERROR,$link='http://curl.haxx.se/libcurl/c/libcurl-errors.html');}
    else { watchdog('shoutcast','Shoutcast stats fetched code(%code): %result', array('%result'=>$xml, '%code'=>$errnum),WATCHDOG_NOTICE);
}
curl_close($ch);

You should use drupal_http_request() instead.

     $xml_cache = cache_get('shoutcast');

if ((!$xml_cache) || ($xml_cache->expire < time())) {
...
}
else {
	$xml= cache_get('shoutcast');

(minor) You're needlesly loading from cache twice.

      $block_content .= "<table style=\"Font-Size:10px\">";
      
      $display_fields = variable_get('shoutcast_display_fields', array('currentlisteners', 'peaklisteners','averagetime','streamstatus','songtitle'));
      
      // when using checkboxes we have to cast the variable as a string?
      if ((string)$display_fields['currentlisteners'] == 'currentlisteners') {
        $block_content .= "<tr><td valign=\"top\">Current:</td><td>". $xml->CURRENTLISTENERS."</td></tr>";
      }
      if ((string)$display_fields['peaklisteners'] == 'peaklisteners') {
        $block_content .= "<tr><td>Most Listeners:</td><td>". $xml->PEAKLISTENERS ."</td></tr>";
      }

You should use theme_table().

       $shoutcast_ip = variable_get('shoutcast_ip', "wunh.org");
	$shoutcast_port = variable_get('shoutcast_port', "8000");
	$shoutcast_pw = variable_get('shoutcast_pw', "password");	
    $shoutcast_feed_url = "http://$shoutcast_ip:$shoutcast_port/admin.cgi?pass=$shoutcast_pw&mode=viewxml";
  $response = drupal_http_request($shoutcast_feed_url);
  $xml = simplexml_load_string($response->data);
  
  $page_content .= "<br /><div align=\"center\">
  <p>".var_dump($xml)."</p></div>";

Debugging variables, probably not suitable for public consumption.

avpaderno’s picture

The module has the same purpose of an already existing module, and it is what we classify as duplicate project.

Is there any reason to not take over the existing module, considering it doesn't has an existing version for Drupal 6?

yohnson’s picture

I have contacted the current maintainer of module with name 'Shoutcast'. I will await their response for taking over the un-maintained module.

Alternatively I also think the module title could be more specific to the purpose which is 'Shoutcast Statistics' because this module does have a focused purpose of integration.

avpaderno’s picture

Status: Needs work » Closed (won't fix)

There have not been replies in the past 7 days. I am marking this report as won't fix.

yohnson’s picture

Status: Closed (won't fix) » Fixed
StatusFileSize
new3.33 KB

kiamlaluno - Changes made as requested - Using durpal_http_request & drupal theme function for table production

avpaderno’s picture

Status: Fixed » Closed (won't fix)

Please re-apply for a CVS account; this application has been without a reply for almost 6 months.