-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddon.py
62 lines (52 loc) · 2.13 KB
/
addon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#
# Copyright (C) 2013 Tommy Winther
# http://tommy.winther.nu
#
# This Program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This Program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this Program; see the file LICENSE.txt. If not, write to
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# http://www.gnu.org/copyleft/gpl.html
#
import re
import os
import sys
import urllib2
import buggalo
import xbmcgui
import xbmcaddon
import xbmcplugin
BASE_URL = 'http://www.gametest.dk/'
PLAY_VIDEO_PATH = 'plugin://plugin.video.youtube/?action=play_video&videoid=%s'
PLAYLIST_PATH = 'plugin://plugin.video.youtube/?channel=GametestDanmark&path=%2froot%2fsubscriptions&user_feed=uploads'
if __name__ == '__main__':
ADDON = xbmcaddon.Addon()
HANDLE = int(sys.argv[1])
ICON = os.path.join(ADDON.getAddonInfo('path'), 'icon.png')
FANART = os.path.join(ADDON.getAddonInfo('path'), 'fanart.jpg')
try:
u = urllib2.urlopen(BASE_URL)
html = u.read()
u.close()
m = re.search('//www.youtube.com/embed/([^"]+)"', html, re.DOTALL)
if m:
videoId = m.group(1)
item = xbmcgui.ListItem(ADDON.getLocalizedString(30000), iconImage=ICON)
item.setProperty('Fanart_Image', FANART)
item.setProperty("IsPlayable", "true")
xbmcplugin.addDirectoryItem(HANDLE, PLAY_VIDEO_PATH % videoId, item)
item = xbmcgui.ListItem(ADDON.getLocalizedString(30001), iconImage=ICON)
item.setProperty('Fanart_Image', FANART)
xbmcplugin.addDirectoryItem(HANDLE, PLAYLIST_PATH, item, True)
xbmcplugin.endOfDirectory(HANDLE)
except:
buggalo.onExceptionRaised()