-
Notifications
You must be signed in to change notification settings - Fork 7
/
plugin.py
66 lines (55 loc) · 1.9 KB
/
plugin.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
62
63
64
65
66
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2012 Tristan Fischer (sphere@dersphere.de)
#
# 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
#
import sys
import urlparse
import xbmc
import xbmcgui
import xbmcplugin
from thebigpictures import ScraperManager
def show_photos(scraper_id, album_url):
scraper_manager = ScraperManager()
scraper_manager.switch(scraper_id)
for photo in scraper_manager.get_photos(album_url):
li = xbmcgui.ListItem(
label=photo['title'],
thumbnailImage=photo['pic']
)
li.setInfo(type='image', infoLabels={'Title': photo['title']})
xbmcplugin.addDirectoryItem(
handle=int(sys.argv[1]),
url=photo['pic'],
listitem=li,
isFolder=False
)
xbmcplugin.endOfDirectory(int(sys.argv[1]))
def decode_params():
params = {}
p = urlparse.parse_qs(sys.argv[2][1:])
for key, value in p.iteritems():
params[key] = value[0]
log('params=%s' % params)
return params
def log(msg):
xbmc.log('TheBigPictures Plugin: %s' % msg)
if __name__ == '__main__':
log('run started in photos-mode')
params = decode_params()
scraper_id = int(params['scraper_id'])
album_url = params['album_url']
show_photos(scraper_id, album_url)