Last active
August 29, 2015 14:00
-
-
Save alan5281/02820b17ca101a324753 to your computer and use it in GitHub Desktop.
自製頻道儲存 http://diy0.xlphp.net/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localStorage.setItem('myjson/channels', JSON.stringify([ | |
{"url":"http://api.ustream.tv/json/channel/18174265/getInfo"}, | |
{"url":"http://www.ustream.tv/embed/17992061"}, masaru-南部實況轉播 | |
{"url":"http://api.ustream.tv/json/channel/18166471/getInfo"}, DeconstructCSSTA | |
{"url":"http://api.ustream.tv/json/channel/17012502/getInfo"}, 【沃草國會無雙】第一競技場 | |
// {"url":"http://api.ustream.tv/json/channel/18070594/getInfo"}, | |
{"url":"http://api.ustream.tv/json/channel/17981427/getInfo"}, yokw7597 | |
{"url":"http://api.ustream.tv/json/channel/17969826/getInfo"}, flyfish1130 | |
{"url":"http://api.ustream.tv/json/channel/18030256/getInfo"}, 阿凱 公民覺醒紀錄 | |
{"url":"http://api.ustream.tv/json/channel/17996833/getInfo"}, sharon chen | |
{"url":"http://api.ustream.tv/json/channel/17157275/getInfo"}, pennyken | |
// {"url":"http://api.ustream.tv/json/channel/18022477/getInfo"}, 小米電台 | |
// {"url":"http://api.ustream.tv/json/channel/18032528/getInfo"}, a22275888 | |
{"url":"http://api.ustream.tv/json/channel/17863662/getInfo"}, 點點記錄 | |
{"url":"http://api.ustream.tv/json/channel/17894339/getInfo"}, afrayang211 | |
{"url":"http://api.ustream.tv/json/channel/17948037/getInfo"}, 豪豬台 | |
{"url":"http://api.ustream.tv/json/channel/17981719/getInfo"}, sharon971119 | |
{"url":"http://api.ustream.tv/json/channel/17929143/getInfo"}, 小六台線上直播 | |
// {"url":"http://api.ustream.tv/json/channel/12933307/getInfo"}, art1025 | |
{"url":"http://api.ustream.tv/json/channel/13620594/getInfo"}, Movement 56 | |
// {"url":"http://api.ustream.tv/json/channel/13750179/getInfo"}, u01120033 | |
{"url":"http://api.ustream.tv/json/channel/17513092/getInfo"}, 拖鞋直播 | |
{"url":"http://api.ustream.tv/json/channel/17562385/getInfo"}, 麵線Noodlesking | |
// {"url":"http://api.ustream.tv/json/channel/17568654/getInfo"}, 南民思潮 | |
{"url":"http://api.ustream.tv/json/channel/17622630/getInfo"}, 公民記者Bananana | |
// {"url":"http://api.ustream.tv/json/channel/17640717/getInfo"}, peopleboss | |
{"url":"http://api.ustream.tv/json/channel/17805218/getInfo"}, duncanparker | |
{"url":"http://api.ustream.tv/json/channel/17811041/getInfo"}, 公民記者-Sean | |
{"url":"http://api.ustream.tv/json/channel/17843610/getInfo"}, 電池線上直播 | |
{"url":"http://api.ustream.tv/json/channel/17866960/getInfo"}, 駿馬線上 - 小駿 | |
{"url":"http://api.ustream.tv/json/channel/17875679/getInfo"}, 影弟FilmBrother 公民記者直播台 | |
{"url":"http://api.ustream.tv/json/channel/17890296/getInfo"}, 雨停inlive | |
// {"url":"http://api.ustream.tv/json/channel/17895878/getInfo"}, 停建核四大遊行427-直播3號 | |
// {"url":"http://api.ustream.tv/json/channel/17905305/getInfo"}, 20140427 公投盟反核 | |
{"url":"http://api.ustream.tv/json/channel/17916604/getInfo"}, 阿賢文旦直播台 | |
// {"url":"http://api.ustream.tv/json/channel/17919218/getInfo"}, rielf1209 宜蘭人 | |
// {"url":"http://api.ustream.tv/json/channel/17920008/getInfo"}, 姐姐。五塊 林森南路八巷直播 | |
// {"url":"http://api.ustream.tv/json/channel/17920466/getInfo"}, ppp726872685 | |
// {"url":"http://api.ustream.tv/json/channel/17920583/getInfo"}, hama0318 | |
// {"url":"http://api.ustream.tv/json/channel/17941683/getInfo"}, harakuros | |
// {"url":"http://api.ustream.tv/json/channel/17950824/getInfo"}, hanstw | |
// {"url":"http://api.ustream.tv/json/channel/17958896/getInfo"}, | |
// {"url":"http://api.ustream.tv/json/channel/17969899/getInfo"}, 割闌尾行動@信義區 20140504 1400 | |
// {"url":"http://api.ustream.tv/json/channel/17974072/getInfo"}, 『捍衛民主,還我喇叭』中正一直擊! | |
{"url":"http://api.ustream.tv/json/channel/7468658/getInfo"}, 文源LIVE秀 | |
{"url":"https://api.youtube.com/user/aorft01/live"} | |
])); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load jQuery script | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | |
ga.onload = function() { | |
var mychannels = JSON.parse(localStorage.getItem('mychannels')); | |
if (Array.isArray(mychannels) === false) { | |
mychannels = []; | |
} | |
// add window | |
var j = jQuery.noConflict(); | |
var max_height = window.innerHeight; | |
var max_width = window.innerWidth-15; | |
var offset_x = parseInt(j('body').attr('offset_x')) || 15; | |
var offset_y = parseInt(j('body').attr('offset_y')) || 15; | |
var alt = parseInt(j('body').attr('alt')) || 1; | |
var default_width = 400, default_height = 360; | |
console.log('MW '+max_width+' MH '+max_height); | |
var add_window = function(elem) { | |
var obc = j('<div class="qv0"><span class="qvt" onclick="geti(this,5);">#</span><span class="qvt" onclick="geti(this,2);">◐</span><span class="qvt" onclick="geti(this,3);">↻</span><span class="qvt" onclick="geti(this,4);">–</span><span class="qvt" onclick="geti(this,0);">×</span><span class="qvt2" onclick="geti(this,1);"></span></div>').attr('alt', alt); | |
j(obc).find('.qvt2').text(elem.title); | |
j('#se2').append(obc); | |
var ob = j('<div class="dd0" onmousedown="getFocus(this);"><div class="dd1"><span class="ss1" onmousedown="md(this,event);"></span><span class="ss5" onclick="wre(this);">↻</span><span class="ss2" onclick="min(this);">–</span><span class="ss3" onclick="cls(this);">×</span><span class="ss7" onclick="ore(this);">◐</span></div><div class="dd8"><iframe frameborder="0" scrolling="no"></iframe><div class="poe" style="display:none;" onmousedown="return false;"></div></div><span class="ss6" onmousedown="md(this,event,1);">⊿</span></div>'); | |
j(ob).css({'top':offset_y+'px','left':offset_x+'px'}).attr('id', elem.key).attr('alt', alt).find('.ss1').text(elem.title); | |
j(ob).find('iframe').width(default_width).height(default_height); | |
j(ob).find('.poe').height(default_height-12); | |
j('body').append(ob); | |
alt = alt + 1; | |
if ((offset_x+default_width) > max_width) { | |
offset_x = 15; | |
offset_y = offset_y + default_height + 15; | |
} else { | |
offset_x = offset_x + default_width; | |
} | |
var rand = Math.round(Math.random() * 9500) + 500; | |
setTimeout (function() { | |
j('#'+elem.key).find('iframe').attr('src',elem.url); | |
}, rand); | |
}; | |
j('body').attr({'offset_x':offset_x, 'offset_y':offset_y, 'alt':alt}); | |
for(var idx = 0; idx < localStorage.length; idx ++) { | |
var key = localStorage.key(idx); | |
if (j('#'+key).length != 0) continue; | |
if (/^ustream-[0-9]+$/.test(key)) { | |
var ob = JSON.parse(localStorage.getItem(key)); | |
if (ob.status == "live") { | |
ob.url = 'http://www.ustream.tv/embed/'+ob.id; | |
ob.key = key; | |
add_window (ob); | |
console.info('%custream%c "%c%s%c" %clive', 'color:#38f', 'color:inherit', 'color:green', ob.title, 'color:inherit', 'color:red'); | |
} | |
} else if (/^youtube-.+$/.test(key)) { | |
var ob = JSON.parse(localStorage.getItem(key)); | |
ob.url = 'https://www.youtube.com/embed/'+ob.videoid+'?feature=player_embedded'; | |
ob.key = key; | |
add_window (ob); | |
console.info('YouTube "%c%s%c" %clive', 'color:green', ob.title, 'color:inherit', 'color:red'); | |
} | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | |
ga.onload = function() { | |
var mychannels = JSON.parse(localStorage.getItem('mychannels')); | |
if (Array.isArray(mychannels) === false) { | |
mychannels = []; | |
} | |
var j = jQuery.noConflict(); | |
j(mychannels).each(function(idx,elem) { | |
var ustream_rex = /^http:\/\/www\.ustream\.tv\/embed\/([0-9]+)$/.exec(elem.url); | |
if (ustream_rex !== null) { | |
var id = ustream_rex[1]; | |
if (j('#ustream-'+id).length != 0) return; | |
var delay = Math.round(Math.random() * 9500) + 500; | |
setTimeout (function() { | |
j.getJSON('https://api.ustream.tv/json/channel/'+ustream_rex[1]+'/getInfo?callback=?', function(data) { | |
if (data.user.id == null) { | |
mychannels.splice(idx,1); | |
localStorage.setItem('mychannels', JSON.stringify(mychannels)); | |
return; | |
} | |
var ob = {}; | |
ob.id = data.id; | |
ob.channel= data.urlTitleName; | |
ob.title = data.title; | |
ob.status = data.status; | |
ob.numberOf = data.numberOf; | |
localStorage.setItem('ustream-'+ob.id, JSON.stringify(ob)); | |
if (ob.status == 'live') { | |
console.log('%custream%c "%c%s%c" %s #%s %c%s', 'color:red', 'color:inherit', 'color:green', ob.title, 'color:inherit', ob.id, ob.channel, 'color:red', ob.status); | |
} else { | |
console.log('%custream%c "%c%s%c" %s #%s %s', 'color:#38f', 'color:inherit', 'color:green', ob.title, 'color:inherit', ob.id, ob.channel, ob.status); | |
} | |
}); | |
}, delay); | |
return; | |
} | |
var youtube_rex = /^https:\/\/www\.youtube\.com\/user\/(\w+)\/live$/.exec(elem.url); | |
if (youtube_rex !== null) { | |
var user = youtube_rex[1]; | |
if (j('#youtube-'+user).length != 0) return; | |
var delay = Math.round(Math.random() * 9500) + 500; | |
setTimeout (function() { | |
j.get('https://gdata.youtube.com/feeds/api/users/'+user+'/live/events?max-results=1&status=active&v=2&inline=true', function(data) { | |
var result = parseInt(j(data).find('totalResults').text()); | |
if (result == 0) { | |
localStorage.removeItem('youtube-'+user); | |
console.log('YouTube user "%c%s%c"', 'color:green', user, 'color:inherit'); | |
return; | |
} | |
var ob = {}; | |
ob.credit = user; | |
ob.videoid = j(data).find('videoid').text(); | |
ob.status = j(data).find('status').text(); | |
ob.title = j(data).find('title').text(); | |
ob.display = j(data).find('author > name').text(); | |
localStorage.setItem('youtube-'+ob.credit, JSON.stringify(ob)); | |
console.info('YouTube "%c%s%c" author: "%c%s%c" user: %s videoid: %c%s%c', 'color:green', ob.title, 'color:inherit', 'color:green', ob.display, 'color:inherit', ob.credit, 'color:red', ob.videoid, 'color:inherit'); | |
}, "xml"); | |
}, delay); | |
return; | |
} | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
localStorage.setItem('mychannels', JSON.stringify([ | |
{"url":"http://www.ustream.tv/embed/18401148"}, | |
{"url":"http://www.ustream.tv/embed/18127743"}, | |
{"url":"http://www.ustream.tv/embed/18380808"}, | |
{"url":"http://www.ustream.tv/embed/18262947"}, | |
{"url":"http://www.ustream.tv/embed/18390482"}, | |
{"url":"http://www.ustream.tv/embed/17857738"}, | |
{"url":"http://www.ustream.tv/embed/17568654"}, | |
{"url":"http://www.ustream.tv/embed/17923438"}, | |
{"url":"http://www.ustream.tv/embed/18103859"}, | |
{"url":"http://www.ustream.tv/embed/18379958"}, | |
{"url":"http://www.ustream.tv/embed/17878254"}, | |
{"url":"http://www.ustream.tv/embed/18174265"}, | |
{"url":"http://www.ustream.tv/embed/17992061"}, | |
{"url":"http://www.ustream.tv/embed/18166471"}, | |
{"url":"http://www.ustream.tv/embed/17012502"}, | |
{"url":"http://www.ustream.tv/embed/17981427"}, | |
{"url":"http://www.ustream.tv/embed/17950934"}, | |
{"url":"http://www.ustream.tv/embed/17969826"}, | |
{"url":"http://www.ustream.tv/embed/18030256"}, | |
{"url":"http://www.ustream.tv/embed/17996833"}, | |
{"url":"http://www.ustream.tv/embed/17157275"}, | |
{"url":"http://www.ustream.tv/embed/17948037"}, | |
{"url":"http://www.ustream.tv/embed/17894339"}, | |
{"url":"http://www.ustream.tv/embed/17981719"}, | |
{"url":"http://www.ustream.tv/embed/17863662"}, | |
{"url":"http://www.ustream.tv/embed/17929143"}, | |
{"url":"http://www.ustream.tv/embed/13620594"}, | |
{"url":"http://www.ustream.tv/embed/17513092"}, | |
{"url":"http://www.ustream.tv/embed/17562385"}, | |
{"url":"http://www.ustream.tv/embed/17622630"}, | |
{"url":"http://www.ustream.tv/embed/17805218"}, | |
{"url":"http://www.ustream.tv/embed/17811041"}, | |
{"url":"http://www.ustream.tv/embed/17843610"}, | |
{"url":"http://www.ustream.tv/embed/17866960"}, | |
{"url":"http://www.ustream.tv/embed/17875679"}, | |
{"url":"http://www.ustream.tv/embed/17890296"}, | |
{"url":"http://www.ustream.tv/embed/17916604"}, | |
{"url":"http://www.ustream.tv/embed/7468658"}, | |
{"url":"https://www.youtube.com/user/aorft01/live"}, | |
{"url":"https://www.youtube.com/user/g0vTW/live"}, | |
{"url":"https://www.youtube.com/user/indietaiwan/live"}, | |
{"url":"https://www.youtube.com/user/ShotForDemocracy/live"} | |
])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment