|
Hi there,
UPDATE: I got a LOT of questions about the TwitchList channel switcher I created for my website www.maegis.net. I created a standalone code that can be easily integrated into any website with minimal html skills. You can find an example site of the "as is" code at http://www.maegis.net/twitchlist/. To download the code + images in a convenient zipfile go to this link zipfile
Abstract With this topic I want to introduce to the team liquid community, a script that generates a stream list for your website composed of stream channels selected by you. The required files can be downloaded from links below.
Background This last week I have been working on my new teams website and decided that I wanted to have a custom stream-list module to tell if any of our teams members where currently streaming. Sadly I discovered there were no such modules available and the pieces of code I did find where ridiculously slow.
the script So I decided to create my own script and now that it is working I want to make it available for other teams that want one on their website.
So what does the script do? It checks a custom list of twitch channel names for being off or online. If a channel is found to be online the title is showed as well as the amount of viewers watching the stream. Here is an image of it working on my joomla based team site. www.maegis.net.
For now the script comes in 2 forms, as a single php file with some images that anyone should be able to incorporate to their site and as a joomla module.
The php file To make the script file work the following line must be edited to check the twitch channels of your choosing. members = array("maegis","androide456","avonmexicola","iksf"); the names between "" are all twitch tv stream channel (i.e. http://www.twitch.tv/maegis ). Simply add the channels names of your choosing separated by a comma and the script should do the rest.
the Joomla module The joomla module is version 2.5 compatible and can be installed using the joomla back-end admin panel. From here navigate to Extensions -> Extension manager and choose upload package file. Select the mod_twitchlist.zip file and press upload. After a successful installation go to Extensions -> Module Manager and enable the Twitch List module. Click on the Twitch link to configure it. Make sure you add a position and assign the module to some of your pages. Under basic options you can add the user list. This list is once again a comma separated list of twitch channels (i.e. eg_idra,rootcatz,liquidhero ) make sure not to use spaces. The module should now appear and function on your joomla website.
Download locations For now both zip files can be downloaded from my website. You can get the joomla module here and the php script file + images here
Future plans and development This is of course still a very early version of the script. I intend to develop a full component that can fill an entire page featuring thumbnails and viewers in a next release. If meanwhile you have any suggestions for features please post them in this topic and I'll see what I can do. I hope some of you will enjoy using this module as much as I enjoyed making it.
Cheers,
Avon
|
I can confirm this is awesome
|
I can confirm this is reasonably well done
|
|
Looks sweet, how long it take to make?
|
That's awesome! Make sure that you check whether the cURL extension (http://php.net/manual/en/book.curl.php) is available because file_get_contents won't work on a lot of shared hosts because they generally turn (http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen) off.
|
On December 29 2012 00:34 WillS wrote: That's awesome! Make sure that you check whether the cURL extension (http://php.net/manual/en/book.curl.php) is available because file_get_contents won't work on a lot of shared hosts because they generally turn (http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen) off.
I believe this function is only used in the joomla mod, for getting the list of channel users from twitch (for joomla to funtion this function has to be available). The none joomla script requires you to add this list into the twitch_list.php yourself.
|
On December 28 2012 01:07 lordofsoup wrote: Looks sweet, how long it take to make?
Since it was the first time I ever tried coding anything in PHP.. a week lol. I went from ~700 lines back to ~70 hahaha.
|
I think you can refactor quite a bit in your code, when it comes to readability. I didn't check the Joomla code since I'm not familiar with any functions concerning Joomla, but I saw some things that had me wondering in the normal PHP code.
You don't need to initialize the counter variable in every foreach loop if you don't use it. By standard it always uses the $value variable. Try to name the $value in a fashion so everyone knows what is in the value, just by looking at the loop. Also since $i and $value are both loop variables you don't need to unset them after your loop is finished (not really a mistake, but it reduces the lines used)
Those are just two things I just saw looking at the code in editor, maybe I can give you some more advice later today
But all in all I like the idea and the code is really good for your first PHP code :D
**EDIT**
I refactored the code a bit and changed/deleted some functions (used in_array instead of two foreach loops) You can look at it here: http://pastebin.com/vQJZ5r7C
Hope it is okay
|
Cool thanks, I will have a look
|
|
Cool! Thanks for sharing.
|
Awesome, been what I have been looking for. Mind releasing the code that you have on your website, or a walkthrough? I am using the joomla module, but I want the stream links to link to my own internal page where it passes the user variable into an iframe of sorts.
Thanks!
|
Hi. Thx for the Code. But can someone help me. I want to integrate in the streamlist also hashd.tv streams. I try everythink but it doesnt work. PLS help.
Thx Ronagan
|
Hi people, I got a lot of pm's about the stream list thingie located at www.maegis.net.SO i created the following update to the topic:
UPDATE: I got a LOT of questions about the TwitchList channel switcher I created for my website www.maegis.net. I created a standalone code that can be easily integrated into any website with minimal html skills. You can find an example site of the "as is" code at http://www.maegis.net/twitchlist/. To download the code + images in a convenient zipfile go to this link zipfile
@Ronagan Please see if that code helps you!
|
Is this available to Blogger.com?
There is Widget > HTML / Javascript there
I was really looking for such thing.
|
Surprised to see that you didn't use my refactored version up until now, since it's much cleaner and has about 50 lines less code.
@Ronagan hasd.tv uses pretty much the same API as twitch.tv does, you just need to change some indeces when filling your arrays and checking the return array. And you need to check every channel by its own, since you can't hand over a list of channels.
|
On May 26 2013 22:03 Zumm wrote: Surprised to see that you didn't use my refactored version up until now, since it's much cleaner and has about 50 lines less code.
@Ronagan hasd.tv uses pretty much the same API as twitch.tv does, you just need to change some indeces when filling your arrays and checking the return array. And you need to check every channel by its own, since you can't hand over a list of channels.
I tried using your version, but did not get it to work!.. therefore I simply went back to what did work.
|
this script doesnt work.Is any possible to add on page automatcaly online streams from directory League of Legends?I mean streams not their status.Wordpress or Joomla or whatever.
|
Just what I was looking for, about to try it on Joomla now, thanks man.
|
|
|
|