-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaddon.py
126 lines (88 loc) · 3.14 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from xbmcswift2 import Plugin, xbmcgui
from resources.lib import abcradionational
plugin = Plugin()
# base url for fetching podcasts
URL = "http://abc.net.au/radionational"
@plugin.route('/')
def main_menu():
"""
main menu
"""
items = [
{
'label': plugin.get_string(30000),
'path': "http://www.abc.net.au/radio/stations/RN/live?play=true",
'thumbnail': "http://www.abc.net.au/local/global_img/programs/howtolisten.jpg",
'is_playable': True},
{
'label': plugin.get_string(30001),
'path': plugin.url_for('just_in'),
'thumbnail': "https://pbs.twimg.com/profile_images/470802028856213504/A4Dg37Ey_400x400.jpeg"},
{
'label': plugin.get_string(30002),
'path': plugin.url_for('subject_list'),
'thumbnail': "https://pbs.twimg.com/profile_images/470802028856213504/A4Dg37Ey_400x400.jpeg"},
{
'label': plugin.get_string(30003),
'path': plugin.url_for('program_list'),
'thumbnail': "https://pbs.twimg.com/profile_images/470802028856213504/A4Dg37Ey_400x400.jpeg"},
]
return items
@plugin.route('/just_in/')
def just_in():
"""
contains playable podcasts listed as just-in
"""
soup = abcradionational.get_soup(URL + "/podcasts")
playable_podcast = abcradionational.get_playable_podcast(soup)
items = abcradionational.compile_playable_podcast(playable_podcast)
return items
@plugin.route('/subject_list/')
def subject_list():
"""
contains a list of navigable podcast by subjects
"""
items = []
soup = abcradionational.get_soup(URL + "/podcasts/subjects")
subject_heading = abcradionational.get_podcast_heading(soup)
for subject in subject_heading:
items.append({
'label': subject['title'],
'path': plugin.url_for('subject_item', url=subject['url']),
})
return items
@plugin.route('/subject_item/<url>/')
def subject_item(url):
"""
contains the playable podcasts for subjects
"""
soup = abcradionational.get_soup(url)
playable_podcast = abcradionational.get_playable_podcast(soup)
items = abcradionational.compile_playable_podcast(playable_podcast)
return items
@plugin.route('/program_list/')
def program_list():
"""
contains a list of navigable menu items by program name
"""
items = []
soup = abcradionational.get_soup(URL + "/podcasts/program")
program_heading = abcradionational.get_podcast_heading(soup)
for program in program_heading:
items.append({
'label': program['title'],
'path': plugin.url_for('program_item', url=program['url']),
})
return items
@plugin.route('/program_list/<url>/')
def program_item(url):
"""
contains the playable podcasts for program names
"""
items = []
soup = abcradionational.get_soup(url)
playable_podcast = abcradionational.get_playable_podcast(soup)
items = abcradionational.compile_playable_podcast(playable_podcast)
return items
if __name__ == '__main__':
plugin.run()