• 0

Only Showing Online Streams?


Question

Hello everyone, I run a gaming website for League of Legends called DominateDominion.com and some people stream their gameplay. I was wondering how I go about having a section on my website or forum that only shows streams that are online broadcasting? Here is an example. http://solomid.net/streams.php It's only showing streams that are currently online and also has featured ones. I am trying to get the same thing with a randomly rotating featured one but don't know where to begin. Any help is much appreciated. Thanks!

Link to comment
https://www.neowin.net/forum/topic/1076477-only-showing-online-streams/
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Are you aware of the JTV gaming category API (AKA Twitch.tv) available as an XML here http://api.justin.tv/api/stream/list.xml?category=gaming

For League of Legends specific games this should suffice http://api.justin.tv/api/stream/list.xml?category=gaming&meta_game=League%20of%20Legends

Parse that XML using PHP's simplexml or whatever you want to use. You can check for featured in the XML schema and using PHP's rand() will get you a random number for use with random streams.

  • 0

Are you aware of the JTV gaming category API (AKA Twitch.tv) available as an XML here http://api.justin.tv...category=gaming

For League of Legends specific games this should suffice http://api.justin.tv...%20of%20Legends

Parse that XML using PHP's simplexml or whatever you want to use. You can check for featured in the XML schema and using PHP's rand() will get you a random number for use with random streams.

So i'm not really sure what XML is or parsing. Know of any guides that would tell me how to do what you're saying?

  • 0

If you have never used XML parsing then maybe the json API would be easier?

I quickly came up with this:

<?php

$json = file_get_contents("http://api.justin.tv/api/stream/list.json?category=gaming&meta_game=League%20of%20Legends");

$elements = json_decode($json);

foreach ($elements as $element) {

	    /*$channel = get_object_vars($element->channel);
	    print_r(array_keys($channel)); // Use this to print out all available keys for the channel array
	   */
	    echo '<strong>', $element->title, '</strong> | '; // Prints out stream title
	    echo $element->stream_count, '<br />'; // Prints out stream viewer count

	    echo '<a href="', $element->channel->channel_url, '">'; // Enables hyperlink to channel
	    echo '<img src="', $element->channel->screen_cap_url_large, '" />'; // Prints out an image
	    echo '</a>';

	    //$element->channel->embed_code; // Prints out a embedded flash video

	    echo '<br /><br />';
}

Try run that on your web server. It requires error trapping and file caching from that URL for a better experience. But basically it prints out the title of the stream, stream viewer numbers and an image of the channel with a hyperlink back to twitch.

  • 0

Its PHP. So you need to save this as a .php file then upload to your web server.

Then you can direct your web browser to open the .php file from the webserver then it should load.

Edit: you can't just pasted it into WordPress or something. It has to run long side WordPress unless you want to try to create a WordPress plug-in which will complicate things.

Or you could use this for WordPress instead http://wordpress.org/extend/plugins/exec-php/ (I've never used WordPress, so I can't really help on that).

  • 0

Its PHP. So you need to save this as a .php file then upload to your web server.

Then you can direct your web browser to open the .php file from the webserver then it should load.

Edit: you can't just pasted it into WordPress or something. It has to run long side WordPress unless you want to try to create a WordPress plug-in which will complicate things.

Or you could use this for WordPress instead http://wordpress.org...ugins/exec-php/ (I've never used WordPress, so I can't really help on that).

I tried that plug-in you linked me, but it didn't work. Nothing showed up when I pasted the code. So I guess i'll try to do the first way you mentioned. So I just go to my server, create a new page title whatever.php with the code you gave me? Then If i go to that page it will show live streams?

  • 0

Yes. Play around. Obviously, make sure you take backups before you commit anything live.

The best way to develop these things is by using a local PHP web server so if you mess anything up, then it doesn't matter. Though if that isn't possible, then make sure you don't overwrite anything you currently have on your web server.

BTW this is the output of the script:

nM0Z0.png

As you can see, you'll need to style it up somewhat using HTML & CSS. Other users here could implement this for you for a little fee if you are not confident enough to undertake it.

  • 0

You can change the game by changing the "game=" URL. Look on twitch.tv for the exact title they use for the game then for example use http://api.justin.tv/api/stream/list.json?category=gaming&meta_game=dominion

If they do not categorise it as a separate game for whatever reason, then you may need to do check the conditions for known users to stream, or check some other element. E.g.

For checking against users:

if ($element->channel->login == 'dominionuser') {

echo $element->channel->embed_code; // This will display the flash video for dominionuser

}

You probably don't want to embed the actual stream from that example, but you may want to display a picture, number of viewers etc.

The code to achieve this is quite simple. I suggest you play around.

Also enabling:

$channel = get_object_vars($element->channel);

print_r(array_keys($channel));

Will print out a list of all the channel information keys. The keys allows you do find the correct key names to allow you to get the language with $element->channel->language or if they are featured using $element->channel->featured for example. Though there's a lot of them you can use.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Microsoft finally admits its default Windows 11 25H2, 24H2 action broke key legacy component by Sayan Sen Microsoft last week released Windows 11 KB5094126 and KB5093998 as the latest Patch Tuesday updates. Following that the company also published the accompanying dynamic updates under KB5094149, KB5095971, and KB5094156. So far the company has acknowledged two known issues that have popped up after the release which include bugged-out Office apps as well as the Recycle Bin; though there could be more at play too. Speaking of bugs and issues, Microsoft seems to have finally acknowledged a problem that probably has been around for close to a year. That's because back in July of 2025 the company made a default change to the latest Windows 11 versions, wherein it switched to JScript9Legacy on Windows 11 24H2 and later releases. Hence following the release of version 25H2 in October 2025, JScript9Legacy also remained default-enabled. As a result there has been a compatibility issue ever since then. For those wondering, by switching to JScript9Legacy Microsoft intended to improve the security of modern Windows PCs by reducing vulnerabilities tied to legacy scripting like cross-site scripting (XSS), among others. XSS exploits can allow cyber-attackers to attach malicious code onto legitimate websites and use them to execute the code when a potential victim loads such a website. Hence the new JScript9Legacy engine enforced stricter execution policies and improved object handling, which should help mitigate such attacks. Microsoft today has published a new support article detailing the problem. Neowin spotted it while browsing. The company says that JScript global definitions and execution context may fail to persist across scripts, potentially breaking older dependent apps and web-based components that relied on this legacy behavior. In the article Microsoft has confirmed that the issue stems from its move away from the older jscript9.dll engine in favor of jscript9legacy.dll. As mentioned above, while the newer engine was designed to address vulnerabilities and strengthen security it also changes how JScript handles execution context. As a result functions and definitions loaded by one script could no longer remain available to subsequent scripts once execution ended. The company notes that some applications worked correctly on earlier Windows versions because the older JScript engine automatically retained global definitions and execution state between scripts. Under the newer model though that behavior is disabled by default causing certain legacy workloads and polyfill-dependent scripts to fail. Microsoft says it addressed the problem via the KB5077241 update though the fix had not been enabled automatically in the following updates. As such admins must explicitly turn on persistent JScript execution context using a Registry setting that the tech giant shared today. The configuration can be applied to individual processes or system-wide through the FEATURE_ENABLE_PERSISTENCE registry key. The steps have been outlined below: Run the following command to create the feature control registry key: reg add "HKLM\Software\Policies\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ENABLE_PERSISTENCE" Under this key, create a new DWORD (32-bit) value. Configure the value as follows: To enable persistence for specific processes only: Set the value to 1 for each target process name. To enable persistence for all processes: Add * as the key name and set its value to 1. You can find the official support article here on Microsoft's website.
    • The possibility that milk gathers back into a glass implies that gravity can be 'reversed'.
    • VidCoder 12.20 by Razvan Serea  VidCoder is a DVD/Blu-ray ripping and video transcoding application for Windows. It uses HandBrake as its encoding engine. Calling directly into the HandBrake library gives it a more rich UI than the official HandBrake Windows GUI. VidCoder can rip DVDs but does not defeat the CSS encryption found in most commercial DVDs. You’ll need the NET 8 Desktop Runtime. If you don’t have it, VidCoder will prompt you to download and install it. The Portable version is self-contained and does not require any .NET Runtime to be installed. You do not need to install HandBrake for VidCoder to work. Feature list: Multi-threaded MP4, MKV containers Completely integrated encoding pipeline: everything is in one process and no huge intermediate temporary files H.264, H.265, MPEG-4, MPEG-2, VP8, Theora video Hardware-accelerated encoding with AMD VCE, Nvidia NVENC and Intel QuickSync AAC, MP3, Vorbis, AC3, FLAC audio encoding and AAC/AC3/MP3/DTS/DTS-HD passthrough Target bitrate, size or quality for video 2-pass encoding Decomb, detelecine, deinterlace, rotate, reflect, chroma smooth, colorspace filters Powerful batch encoding with simultaneous encodes Customizable Pickers to automatically pick audio and subtitle tracks, destination, titles and more Instant source previews Creates small encoded preview clips Pause, resume encoding VidCoder 12.20 changes: Updated HandBrake core to 1.11.2. Download: VidCoder 12.20 | 47.0 MB (Open Source) Download: Portable VidCoder 12.19 | 89.3 MB Link: VidCoder Home Page | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Too soon, I'm still not over this death!
  • Recent Achievements

    • Week One Done
      Jordan Smith earned a badge
      Week One Done
    • Reacting Well
      BizSAR earned a badge
      Reacting Well
    • First Post
      AndreaB earned a badge
      First Post
    • Week One Done
      Huge Trailer earned a badge
      Week One Done
    • Week One Done
      Classifyskilleducation earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      593
    2. 2
      +Edouard
      185
    3. 3
      PsYcHoKiLLa
      76
    4. 4
      Michael Scrip
      73
    5. 5
      Steven P.
      66
  • Tell a friend

    Love Neowin? Tell a friend!