Skip to content

Commit

Permalink
trivial fix for nicolive
Browse files Browse the repository at this point in the history
  • Loading branch information
kazy111 committed May 12, 2012
1 parent 149fef9 commit 701550c
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 41 deletions.
6 changes: 5 additions & 1 deletion assoc_define.php
Expand Up @@ -96,7 +96,11 @@ function get_archive_url($type, $ch_name, $opt_id)
$ret = 'http://www.stickam.jp/video/gallery/'.$ch_name;
break;
case 3: // nicolive
$ret = 'http://com.nicovideo.jp/live_archives/'.$ch_name;
if(substr($ch_name, 0, 2) == 'co'){
$ret = 'http://com.nicovideo.jp/live_archives/'.$ch_name;
}else{
$ret = 'http://live.nicovideo.jp/watch/'.$ch_name;
}
break;
case 4: // twitcasting
$ret = 'http://twitcasting.tv/'.$ch_name.'/show/';
Expand Down
74 changes: 38 additions & 36 deletions check.php
Expand Up @@ -617,54 +617,56 @@ function set_opt( $ch, $cookie_file ){
function check_nicolive_official()
{

global $manager;

// when set no limit_keywords, return this function
if ($GLOBALS['limit_keywords'] == '') {
return;
}

log_print('start checking nicolive(official).');


$url = 'http://live.nicovideo.jp/recent/rss';

log_print($url);
try{
$xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
if (! $xml ) throw new Exception('URL open failed : '.$url);

// add to temporary
$items = $xml->channel->item;
if ($items) {
for ($i = 0; $i < count($items); $i++) {


// if already added, then skip
if ($manager->check_already_registered(3, $items[$i]->guid, NULL)) {
continue;
}
// if program type is community, then skip
$nicolive = $items[$i]->children('http://live.nicovideo.jp/');
if ($nicolive->type == 'community') {
continue;
}
function inner_check($url){
global $manager;
log_print($url);
try{
$xml = simplexml_load_file($url, 'SimpleXMLElement', LIBXML_NOCDATA);
if (! $xml ) throw new Exception('URL open failed : '.$url);

// add to temporary
$items = $xml->channel->item;
if ($items) {
for ($i = 0; $i < count($items); $i++) {


// if already added, then skip
if ($manager->check_already_registered(3, $items[$i]->guid, NULL)) {
continue;
}
// if program type is community, then skip
$nicolive = $items[$i]->children('http://live.nicovideo.jp/');
if ($nicolive->type == 'community') {
continue;
}

// now add streamer as templrary
$desc = addslashes(strip_tags($items[$i]->description));
$check = $items[$i]->title . ' ' . $desc;
if (preg_match('/'.$GLOBALS['limit_keywords'].'/', $check) > 0){
log_print('register to temporary '.$items[$i]->title);
$manager->register($items[$i]->title, $desc,
2, '', 3, $items[$i]->guid, NULL, 1);
// now add streamer as templrary
$desc = addslashes(strip_tags($items[$i]->description));
$check = $items[$i]->title . ' ' . $desc;
if (preg_match('/'.$GLOBALS['limit_keywords'].'/', $check) > 0){
log_print('register to temporary '.$items[$i]->title);
$manager->register($items[$i]->title, $desc,
2, '', 3, $items[$i]->guid, NULL, 1);
}
}
}
}catch(Exception $e){
print $e->getMessage();
continue;
}
}catch(Exception $e){
print $e->getMessage();
continue;
}

log_print('start checking nicolive(official).');

inner_check('http://live.nicovideo.jp/rss');
inner_check('http://live.nicovideo.jp/recent/rss');

log_print('finish checking nicolive(official).');
}

Expand Down
4 changes: 2 additions & 2 deletions classes/database/MySQLDataManager.php
Expand Up @@ -478,8 +478,8 @@ function register($name, $desc, $chat_type, $room, $pg_type, $pg_id, $opt_no, $t
}else
$cid = $tmp['id'];

$this->db->query('insert into program_table (streamer_id, chat_id, type, ch_name, optional_id, live)'
.' values ('.$sid.', '.$cid.', '.$pg_type.', \''.$pg_id.'\',\''.$opt_no.'\', false)');
$this->db->query('insert into program_table (streamer_id, chat_id, type, ch_name, optional_id, live, title)'
.' values ('.$sid.', '.$cid.', '.$pg_type.', \''.$pg_id.'\',\''.$opt_no.'\', false, \''.$desc.'\')');

$this->db->commit();
}catch(Exception $e){
Expand Down
4 changes: 2 additions & 2 deletions classes/database/PostgreSQLDataManager.php
Expand Up @@ -494,8 +494,8 @@ function register($name, $desc, $chat_type, $room, $pg_type, $pg_id, $opt_no, $t
$cid = $tmp['id'];
}

$this->db->query('insert into program_table (streamer_id, chat_id, type, ch_name, optional_id, live)'
.' values ('.$sid.', '.$cid.', '.$pg_type.', \''.$pg_id.'\',\''.$opt_no.'\', false)');
$this->db->query('insert into program_table (streamer_id, chat_id, type, ch_name, optional_id, live, title)'
.' values ('.$sid.', '.$cid.', '.$pg_type.', \''.$pg_id.'\',\''.$opt_no.'\', false, \''.$desc.'\')');

$this->db->commit();
}catch(Exception $e){
Expand Down

0 comments on commit 701550c

Please sign in to comment.