Skip to content

Commit

Permalink
Use hosted resources
Browse files Browse the repository at this point in the history
  • Loading branch information
sander1 committed May 16, 2013
1 parent 5f1583a commit 80c79ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,22 @@

PAGE_LIMIT = 100
NAME = 'Twitch.tv'
ART = 'art-default.jpg'
ICON = 'icon-default.jpg'

####################################################################################################
def Start():

ObjectContainer.art = R(ART)
ObjectContainer.title1 = NAME
DirectoryObject.thumb = R(ICON)

HTTP.Headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:19.0) Gecko/20100101 Firefox/19.0'
HTTP.Headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0'
HTTP.CacheTime = 600

####################################################################################################
@handler('/video/twitch', NAME, thumb=ICON, art=ART)
@handler('/video/twitch', NAME)
def MainMenu():

oc = ObjectContainer()
oc.add(DirectoryObject(key=Callback(FeaturedStreamsMenu), title="Featured Streams"))
oc.add(DirectoryObject(key=Callback(GamesMenu), title="Games", summary="Browse Live Streams by Game"))
oc.add(InputDirectoryObject(key=Callback(SearchResults), title="Search", prompt="Search for a Stream", summary="Search for a Stream", thumb=R('search.png')))
oc.add(InputDirectoryObject(key=Callback(SearchResults), title="Search", prompt="Search for a Stream", summary="Search for a Stream"))

return oc

Expand All @@ -57,7 +52,7 @@ def FeaturedStreamsMenu():
url = stream['stream']['channel']['url'],
title = stream['stream']['channel']['display_name'],
summary = '%s\n\n%s' % (subtitle, summary),
thumb = Resource.ContentsOfURLWithFallback(stream['stream']['preview']['large'], fallback='icon-default.jpg')
thumb = Resource.ContentsOfURLWithFallback(stream['stream']['preview']['large'])
))

return oc
Expand All @@ -77,7 +72,7 @@ def GamesMenu(page=0):
key = Callback(ChannelMenu, game=game['game']['name']),
title = game['game']['name'],
summary = game_summary,
thumb = Resource.ContentsOfURLWithFallback(game['game']['logo']['large'], fallback='icon-default.jpg')
thumb = Resource.ContentsOfURLWithFallback(game['game']['logo']['large'])
))

if len(games['top']) == 100:
Expand All @@ -103,7 +98,7 @@ def ChannelMenu(game):
url = stream['channel']['url'],
title = stream['channel']['display_name'],
summary = '%s\n\n%s' % (subtitle, stream['channel']['status']),
thumb = Resource.ContentsOfURLWithFallback(stream['channel']['logo'], fallback='icon-default.jpg')
thumb = Resource.ContentsOfURLWithFallback(stream['channel']['logo'])
))

return oc
Expand All @@ -124,7 +119,7 @@ def SearchResults(query=''):
url = stream['channel']['url'],
title = stream['channel']['display_name'],
summary = '%s\n\n%s' % (subtitle, stream['channel']['status']),
thumb = Resource.ContentsOfURLWithFallback(stream['channel']['logo'], fallback='icon-default.jpg')
thumb = Resource.ContentsOfURLWithFallback(stream['channel']['logo'])
))

if len(oc) < 1:
Expand Down
Binary file removed Contents/Resources/art-default.jpg
Binary file not shown.
Binary file removed Contents/Resources/icon-default.jpg
Binary file not shown.

2 comments on commit 80c79ac

@jkaberg
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @sander1 . This plugin dosnt seem to work anymore, got any clues as to why?

@sander1
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem was (probably) with the URL Service for Twitch. There have been updates on the service, and when I just tried this channel it worked.

Please sign in to comment.