Check Here To See If Salem Is Streaming On Twitch Or YouTube

Forum for off topic and general discussion.

Re: Check Here To See If Salem Is Currently Streaming

Postby simple69 » Tue Jun 09, 2015 6:17 pm

Good idea putting it in your signature.
User avatar
simple69
 
Posts: 37
Joined: Sun Nov 25, 2012 9:54 pm

Re: Check Here To See If Salem Is Currently Streaming

Postby loftar » Tue Jun 09, 2015 8:09 pm

The source code, just in case it is of use to anyone:
Code: Select all
import wrw, urllib.request, json, time, io
from PIL import Image, ImageDraw
from wrw.proto import urlq

def makedot(color, sz=(12, 12)):
    w, h = sz[0] * 16, sz[1] * 16
    img = Image.new("RGBA", (w, h))
    g = ImageDraw.Draw(img)
    g.ellipse(((4, 4), (w - 5, h - 5)), fill=color)
    img = img.resize(sz, True)
    buf = io.BytesIO()
    img.save(buf, "PNG")
    return buf.getvalue()

# Note: Scientifically tuned and optimized colors; do not change
avail = makedot((186, 217, 100))
inval = makedot((253, 174,  71))
unavl = makedot((230, 104,  89))

cache = {}

def fetch(url):
    now = time.time()
    if url in cache:
        data, mtime = cache[url]
        if now - mtime < 60:
            return data
    with urllib.request.urlopen(url) as req:
        data = req.read()
    cache[url] = data, now
    return data

def game(ch):
    streams = json.loads(str(fetch("http://api.twitch.tv/kraken/streams/%s?on_site=1" % urlq(ch)), "utf-8"))
    if "stream" not in streams or not streams["stream"]:
        return None
    return streams["stream"].get("game")

@wrw.wsgiwrap
@wrw.formparams
def application(req, ch, match=None):
    try:
        cur = game(ch)
    except urllib.error.HTTPError as exc:
        if exc.code == 404:
            raise wrw.resp.usererror("No such user", ch + " does not appear to be a Twitch user.")
        raise
    req.ohead["Content-Type"] = "image/png"
    if cur is None:
        return [unavl]
    elif match is not None and cur != match:
        return [inval]
    else:
        return [avail]
User avatar
loftar
 
Posts: 1021
Joined: Sun Jul 08, 2012 7:32 am
Location: In your character database, shuffling bits

Re: Check Here To See If Salem Is Currently Streaming

Postby Yasso » Thu Jun 11, 2015 5:34 pm

loftar wrote:The source code, just in case it is of use to anyone:
Code: Select all
import wrw, urllib.request, json, time, io
from PIL import Image, ImageDraw
from wrw.proto import urlq

def makedot(color, sz=(12, 12)):
    w, h = sz[0] * 16, sz[1] * 16
    img = Image.new("RGBA", (w, h))
    g = ImageDraw.Draw(img)
    g.ellipse(((4, 4), (w - 5, h - 5)), fill=color)
    img = img.resize(sz, True)
    buf = io.BytesIO()
    img.save(buf, "PNG")
    return buf.getvalue()

# Note: Scientifically tuned and optimized colors; do not change
avail = makedot((186, 217, 100))
inval = makedot((253, 174,  71))
unavl = makedot((230, 104,  89))

cache = {}

def fetch(url):
    now = time.time()
    if url in cache:
        data, mtime = cache[url]
        if now - mtime < 60:
            return data
    with urllib.request.urlopen(url) as req:
        data = req.read()
    cache[url] = data, now
    return data

def game(ch):
    streams = json.loads(str(fetch("http://api.twitch.tv/kraken/streams/%s?on_site=1" % urlq(ch)), "utf-8"))
    if "stream" not in streams or not streams["stream"]:
        return None
    return streams["stream"].get("game")

@wrw.wsgiwrap
@wrw.formparams
def application(req, ch, match=None):
    try:
        cur = game(ch)
    except urllib.error.HTTPError as exc:
        if exc.code == 404:
            raise wrw.resp.usererror("No such user", ch + " does not appear to be a Twitch user.")
        raise
    req.ohead["Content-Type"] = "image/png"
    if cur is None:
        return [unavl]
    elif match is not None and cur != match:
        return [inval]
    else:
        return [avail]

Thank you for letting us change the colours without letting us change the colours ¦]
Yasso
 
Posts: 416
Joined: Wed Aug 01, 2012 2:00 pm

Re: Check Here To See If Salem Is Currently Streaming

Postby Nikixos » Mon Jun 15, 2015 12:53 am

Feather of the brave should be given for 14+ days of streaming not 3. Many People stop streaming after they are given their hat and dont stream because they like to. Like sipo
Image Image
User avatar
Nikixos
 
Posts: 1621
Joined: Mon Jan 21, 2013 9:03 am
Location: Mexico

New Streamer is Streaming

Postby Claeyt » Fri Jun 26, 2015 2:29 am

jorb wrote:(jwhitehorn) you are an ungrateful, spoiled child


As the river rolled over the cliffs, my own laughing joy was drowned out by the roaring deluge of the water. The great cataract of Darwoth's Tears fell over and over endlessly.
User avatar
Claeyt
 
Posts: 5166
Joined: Mon Dec 24, 2012 4:02 pm

Re: Check Here To See If Salem Is Currently Streaming

Postby Dallane » Fri Jun 26, 2015 4:48 am

Merged
Please click this link for a better salem forum experience

TotalyMeow wrote: Claeyt's perspective of Salem and what it's about is very different from the devs and in many cases is completely the opposite of what we believe.
User avatar
Dallane
Moderator
 
Posts: 15195
Joined: Wed Aug 01, 2012 2:00 pm

Re: Check Here To See If Salem Is Currently Streaming

Postby Claeyt » Fri Jun 26, 2015 7:38 am

Dallane wrote:Merged

Thank You, I should have just posted it here anyways. I updated the list to include Doofussmann.

For the record he's got over 1000 followers and over 40,000 unique views on his stream. He got up to 16 I believe tonight which is high for a game like this.

Be sure to follow him and Salem on Twitch to help promote the game.
jorb wrote:(jwhitehorn) you are an ungrateful, spoiled child


As the river rolled over the cliffs, my own laughing joy was drowned out by the roaring deluge of the water. The great cataract of Darwoth's Tears fell over and over endlessly.
User avatar
Claeyt
 
Posts: 5166
Joined: Mon Dec 24, 2012 4:02 pm

Re: Check Here To See If Salem Is Currently Streaming

Postby Claeyt » Fri Jun 26, 2015 8:47 pm

New streamer today. Welcome him to Salem, he's a brand new German player who also speaks english.

http://www.twitch.tv/atego87

Be sure to follow him and to follow the game to help promote the game on Twitch.
jorb wrote:(jwhitehorn) you are an ungrateful, spoiled child


As the river rolled over the cliffs, my own laughing joy was drowned out by the roaring deluge of the water. The great cataract of Darwoth's Tears fell over and over endlessly.
User avatar
Claeyt
 
Posts: 5166
Joined: Mon Dec 24, 2012 4:02 pm

Re: Check Here To See If Salem Is Currently Streaming

Postby Claeyt » Sat Jun 27, 2015 3:20 am

Yet another new streamer:

http://www.twitch.tv/dorrian

Be sure to follow him and follow the game to support the game.

added him to the list.
jorb wrote:(jwhitehorn) you are an ungrateful, spoiled child


As the river rolled over the cliffs, my own laughing joy was drowned out by the roaring deluge of the water. The great cataract of Darwoth's Tears fell over and over endlessly.
User avatar
Claeyt
 
Posts: 5166
Joined: Mon Dec 24, 2012 4:02 pm

Re: Check Here To See If Salem Is Currently Streaming

Postby fox » Sat Jun 27, 2015 1:54 pm

sad thing about some past broadcasts had sound mute :(
Image
Image
Image Unaussprechlichen Kulten
Image De Furtivis Literarum Notis by Giovanni Battista della Porta
fox
 
Posts: 345
Joined: Wed Aug 01, 2012 1:20 am

PreviousNext

Return to City upon a Hill

Who is online

Users browsing this forum: No registered users and 29 guests