Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the Tested XBMC App #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugin.video.tested/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.tested"
name="Tested"
version="2.1"
version="2.2"
provider-name="Whiskey Media">
<requires>
<import addon="xbmc.python" version="2.0"/>
Expand Down
Binary file added plugin.video.tested/art.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions plugin.video.tested/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[B]2.2[/B]
- Switched the Tested Plugin to work off of youtube (since all videos are hosted on their now)

[B]2.1[/B]
- Fixed bug with search for non-subscribers

Expand Down
142 changes: 52 additions & 90 deletions plugin.video.tested/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,114 +5,74 @@
import xbmcplugin
import xbmcgui

API_PATH = 'http://api.tested.com'
API_KEY = 'df91891cf6c7e7475955d876926b3e9cf5a75743' # Default API key
my_addon = xbmcaddon.Addon('plugin.video.tested')

def CATEGORIES():
account_linked = False
user_api_key = my_addon.getSetting('api_key')
if user_api_key:
response = urllib2.urlopen(API_PATH + '/chats/?api_key=' + user_api_key + '&format=json')
data = simplejson.loads(response.read())
if data['status_code'] == 100:
# Revert to the default key
my_addon.setSetting('api_key', '')
else:
global API_KEY
API_KEY = user_api_key
account_linked = True

response = urllib2.urlopen(API_PATH + '/video_types/?api_key=' + API_KEY + '&format=json')
category_data = simplejson.loads(response.read())['results']
response.close()

name = 'Latest'
url = API_PATH + '/videos/?api_key=' + API_KEY + '&sort=-publish_date&format=json'
iconimage = ''
addDir(name, url, 2, '')

for cat in category_data:
name = cat['name']
url = API_PATH + '/videos/?api_key=' + API_KEY + '&video_type=' + str(cat['id']) + '&sort=-publish_date&format=json'
iconimage = ''
addDir(name, url, 2, '')
iconPath = my_addon.getAddonInfo('path') + '\\icons\\'

name = 'Latest'
url = 'https://gdata.youtube.com/feeds/api/users/testedcom/uploads?alt=json&prettyprint=true&v=2&max-results=20'
addDir(name, url, 2, iconPath + "latest.png")

#TODO: ADD IN "ALL", CLICK PAGES TO GO FORWARD
name = 'Science & Technology'
url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&author=testedcom&prettyprint=true&v=2&max-results=50&orderby=published&category=Tech'
addDir(name, url, 2, iconPath + "science.png")

name = 'Reviews'
url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&author=testedcom&prettyprint=true&v=2&max-results=50&orderby=published&category=review'
addDir(name, url, 2, iconPath + "review.png")

name = 'App Of The Day'
url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&author=testedcom&prettyprint=true&v=2&max-results=50&orderby=published&category=app,of,the,day'
addDir(name, url, 2, iconPath + "app-of-the-day.png")

name = 'DIY'
url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&author=testedcom&prettyprint=true&v=2&max-results=50&orderby=published&category=diy'
addDir(name, url, 2, iconPath + "diy.png")

name = 'Coffee'
url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&author=testedcom&prettyprint=true&v=2&max-results=50&orderby=published&category=coffee'
addDir(name, url, 2, iconPath + "coffee.png")

name = 'Howtos'
url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&author=testedcom&prettyprint=true&v=2&max-results=50&orderby=published&category=howto'
addDir(name, url, 2, iconPath + "howto.png")

name = 'Makerbot'
url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&author=testedcom&prettyprint=true&v=2&max-results=50&orderby=published&category=makerbot'
addDir(name, url, 2, iconPath + "makerbot.png")

name = 'Search'
iconimage = ''
addDir(name, 'search', 1, '')
addDir(name, 'search', 1, iconPath + "search.png")

if not account_linked:
name = 'Link Account'
iconimage = ''
addDir(name, 'link', 1, '')

def GET_API_KEY(link_code):
if link_code and len(link_code) == 6:
try:
response = urllib2.urlopen(API_PATH + '/validate?link_code=' + link_code + '&format=json')
data = simplejson.loads(response.read())
new_api_key = data['api_key']
my_addon.setSetting('api_key', new_api_key)
return True
except:
return False
else:
return False

def INDEX(url):
if my_addon.getSetting('api_key'):
global API_KEY
API_KEY = my_addon.getSetting('api_key')

if url == 'search':
keyboard = xbmc.Keyboard("", 'Search', False)
keyboard.doModal()
if keyboard.isConfirmed():
query = keyboard.getText().replace(' ', '%20')
url = API_PATH + '/search/?api_key=' + API_KEY + '&resources=video&query=' + query + '&format=json'
url = 'http://gdata.youtube.com/feeds/api/videos?alt=json&author=testedcom&prettyprint=true&v=2&q=' + query
VIDEOLINKS(url, 'search')

elif url == 'link':
dialog = xbmcgui.Dialog()
ok = dialog.ok("Let's do this.", "To link your account, visit", "www.tested.com/xbmc to get a link code.", "Enter this code on the next screen.")

keyboard = xbmc.Keyboard("", 'Enter your link code.', False)
keyboard.doModal()
if keyboard.isConfirmed():
link_code = keyboard.getText().upper()
if GET_API_KEY(link_code):
ok = dialog.ok("Success!", "Your account is now linked!", "If you are a premium member,", "you should now have premium privileges.")
else:
ok = dialog.ok("We're really sorry, but...", "We could not link your account.", "Make sure the code you entered is correct", "and try again.")
CATEGORIES()

def VIDEOLINKS(url, name):
if my_addon.getSetting('api_key'):
global API_KEY
API_KEY = my_addon.getSetting('api_key')

q_setting = int(my_addon.getSetting('quality'))
quality = None
if q_setting == 1:
quality = 'low_url'
elif q_setting == 2:
quality = 'high_url'

response = urllib2.urlopen(url)
video_data = simplejson.loads(response.read())['results']
video_data = simplejson.loads(response.read())
response.close()

for vid in video_data:
name = vid['name']
if not quality:
if 'hd_url' in vid:
url = vid['hd_url'] + '&api_key=' + API_KEY
else:
url = vid['high_url']
else:
url = vid[quality]
thumbnail = vid['image']['super_url']
for vid in video_data['feed']['entry']:
name = vid['title']['$t']

url = 'plugin://plugin.video.youtube/?action=play_video&quality=720p&videoid=' + vid['media$group']['yt$videoid']['$t'] # to flash file, need to download it I guess?

# Try to get the HD Thumbnail, if you cant than just grab the default one
try:
thumbnail = vid['media$group']['media$thumbnail'][2]['url']
except:
thumbnail = vid['media$group']['media$thumbnail'][0]['url']

addLink(name,url,thumbnail)

def get_params():
Expand All @@ -137,7 +97,9 @@ def addLink(name, url, iconimage):
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
liz.setProperty("fanart_image", my_addon.getAddonInfo('path') + "/fanart.jpg")
liz.setProperty("fanart_image", my_addon.getAddonInfo('path') + "/art.png")
liz.setProperty( "Video", "true" )
liz.setProperty( "IsPlayable", "true")
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
return ok

Expand All @@ -146,7 +108,7 @@ def addDir(name, url, mode, iconimage):
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name } )
liz.setProperty("fanart_image", my_addon.getAddonInfo('path') + "/fanart.jpg")
liz.setProperty("fanart_image", my_addon.getAddonInfo('path') + "/art.png")
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok

Expand Down
Binary file removed plugin.video.tested/fanart.jpg
Binary file not shown.
Binary file modified plugin.video.tested/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/app-of-the-day.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/coffee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/diy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/howto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/latest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/makerbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/review.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/science.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugin.video.tested/icons/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions plugin.video.tested/resources/settings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<setting id="api_key" type="text" default="" option="hidden" label="API Key" visible="false" />
<setting id="quality" type="enum" values="Auto|Low|High" default="0" label="Quality" />
</settings>