Skip to content

Commit d6d8e7f

Browse files
committed
Update to python3
1 parent 2ad1b06 commit d6d8e7f

9 files changed

Lines changed: 126 additions & 91 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
*.pyc
2+
*.pyo
3+
__pycache__
4+
.DS_Store

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

addon.py

100755100644
Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,5 @@
1-
'''
2-
VimCasts XBMC Addon
3-
-------------------
1+
# -*- coding: utf-8 -*-
2+
from resources.lib import plugin
43

5-
Watch screencasts from http://vimcasts.org in XBMC.
6-
7-
:copyright: (c) 2012 by Jonathan Beluch
8-
:license: GPLv3, see LICENSE.txt for more details.
9-
'''
10-
import re
11-
import HTMLParser
12-
from urllib2 import urlopen
13-
try:
14-
import json
15-
except ImportError:
16-
import simplejson as json
17-
from xbmcswift2 import Plugin
18-
19-
20-
PLUGIN_NAME = 'VimCasts'
21-
PLUGIN_ID = 'plugin.video.vimcasts'
22-
plugin = Plugin(PLUGIN_NAME, PLUGIN_ID, __file__)
23-
24-
25-
def get_json_feed():
26-
'''Loads the JSON feed for vimcasts.org.'''
27-
json_url = 'http://vimcasts.org/episodes.json?referrer=xbmc'
28-
conn = urlopen(json_url)
29-
_json = json.load(conn)
30-
conn.close()
31-
return _json
32-
33-
34-
def strip_tags(inp):
35-
'''Naively strips instances of <tag> from the given inp'''
36-
return re.sub('(<.+?>)', '', inp)
37-
38-
39-
_parser = HTMLParser.HTMLParser()
40-
def unescape_html(inp):
41-
'''Replaces named instances of html entities with the corresponding
42-
unescaped character.
43-
44-
>>> unescape_html('apples &amp; oranges')
45-
apples & oranges
46-
'''
47-
return _parser.unescape(inp)
48-
49-
50-
def clean(inp):
51-
'''Strips HTML tags and unescapes named HTML entities for the given input.
52-
53-
>>> clean('<strong>apples &amp; oranges</strong>')
54-
apples & oranges
55-
'''
56-
return unescape_html(strip_tags(inp))
57-
58-
59-
@plugin.route('/')
60-
def index():
61-
'''The main menu and only view for this plugin. Lists available episodes'''
62-
items = [{
63-
'label': '#%s %s' % (epi['episode_number'], epi['title']),
64-
'path': epi['quicktime']['url'],
65-
'thumbnail': epi['poster'],
66-
'info': {
67-
'plot': clean(epi['abstract'])
68-
},
69-
'is_playable': True,
70-
} for epi in get_json_feed()['episodes']]
71-
return items
72-
73-
74-
if __name__ == '__main__':
4+
if __name__ == "__main__":
755
plugin.run()

addon.xml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
1-
<addon id="plugin.video.vimcasts" name="VimCasts" provider-name="Jonathan Beluch (jbel)" version="1.1">
1+
<addon id="plugin.video.vimcasts" name="VimCasts" provider-name="Jonathan Beluch (jbel), enen92" version="1.2.0">
22
<requires>
3-
<import addon="xbmc.python" version="2.0" />
4-
<import addon="script.module.xbmcswift2" version="1.1.1" />
3+
<import addon="xbmc.python" version="2.14.0" />
4+
<import addon="script.module.xbmcswift2" version="2.5.0" />
55
</requires>
66
<extension library="addon.py" point="xbmc.python.pluginsource">
77
<provides>video</provides>
88
</extension>
99
<extension point="xbmc.addon.metadata">
1010
<platform>all</platform>
11-
<language />
11+
<language>en</language>
12+
<source>https://github.com/XBMC-Addons/plugin.video.vimcasts</source>
13+
<news>
14+
Version 1.2.0
15+
* Update to python3
16+
* Update to new xbmcswift2
17+
* Add duration
18+
* Remove unplayable items
19+
* New addon requirements
20+
</news>
1221
<summary>Watch screencasts about Vim, the text editor, from http://vimcasts.org</summary>
1322
<description>Vimcasts publishes free screencasts about Vim, the text editor. Vim has been around in one form or another for over 20 years. The learning curve is famously difficult, but those who manage to climb it insist that nothing can match Vim's modal editing model for speed and efficiency.[CR][CR]The patterns of use that make a Vim master productive are not easily discovered. Trial and error will get you so far, but the best way to learn is to watch an experienced Vim user at work. By providing short videos with digestible advice, Vimcasts gives you something you can take away and use immediately to improve your productivity. Vimcasts aims to be the expert Vim colleague you never had.[CR][CR]Vimcasts is produced by Drew Neil (aka nelstrom), who came to Vim from TextMate. He made the switch when starting work at a company that uses Linux workstations. His choice of text editor was influenced by colleagues.</description>
1423
</extension>

changelog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 1.2.0
2+
-----------
3+
* Update to python3
4+
* Update to new xbmcswift2
5+
* Add duration
6+
* Remove unplayable items
7+
* New addon requirements
8+
19
Version 1.1
210
-----------
311

fanart.jpg

214 KB
Loading
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2-
<strings>
3-
<!-- Plugin name -->
4-
<string id="30000">VimCasts</string>
5-
</strings>
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2+
<strings>
3+
<!-- Plugin name -->
4+
<string id="30000">VimCasts</string>
5+
</strings>

resources/lib/plugin.py

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
'''
2+
VimCasts KODI Addon
3+
-------------------
4+
5+
Watch screencasts from http://vimcasts.org in KODI.
6+
7+
:copyright: (c) 2012 by Jonathan Beluch
8+
:license: GPLv3, see LICENSE.txt for more details.
9+
'''
10+
import re
11+
import sys
12+
try:
13+
import json
14+
except ImportError:
15+
import simplejson as json
16+
from xbmcswift2 import Plugin
17+
18+
PY3 = sys.version_info.major >= 3
19+
20+
if PY3:
21+
from html.parser import HTMLParser
22+
from urllib.request import urlopen
23+
else:
24+
from HTMLParser import HTMLParser
25+
from urllib2 import urlopen
26+
27+
PLUGIN_NAME = 'VimCasts'
28+
PLUGIN_ID = 'plugin.video.vimcasts'
29+
plugin = Plugin(PLUGIN_NAME, PLUGIN_ID, __file__)
30+
31+
32+
def get_json_feed():
33+
'''Loads the JSON feed for vimcasts.org.'''
34+
json_url = 'http://vimcasts.org/episodes.json?referrer=xbmc'
35+
conn = urlopen(json_url)
36+
_json = json.load(conn)
37+
conn.close()
38+
return _json
39+
40+
41+
def strip_tags(inp):
42+
'''Naively strips instances of <tag> from the given inp'''
43+
return re.sub('(<.+?>)', '', inp)
44+
45+
46+
_parser = HTMLParser()
47+
def unescape_html(inp):
48+
'''Replaces named instances of html entities with the corresponding
49+
unescaped character.
50+
51+
>>> unescape_html('apples &amp; oranges')
52+
apples & oranges
53+
'''
54+
return _parser.unescape(inp)
55+
56+
57+
def clean(inp):
58+
'''Strips HTML tags and unescapes named HTML entities for the given input.
59+
60+
>>> clean('<strong>apples &amp; oranges</strong>')
61+
apples & oranges
62+
'''
63+
return unescape_html(strip_tags(inp))
64+
65+
66+
@plugin.route('/')
67+
def index():
68+
'''The main menu and only view for this plugin. Lists available episodes'''
69+
items = [{
70+
'label': '#%s %s' % (epi['episode_number'], epi['title']),
71+
'path': epi['quicktime']['url'],
72+
'thumbnail': epi['poster'],
73+
'fanart': plugin.fanart,
74+
'info': {
75+
'plot': clean(epi['abstract']),
76+
'duration': int(epi['quicktime']['seconds'])
77+
},
78+
'is_playable': True,
79+
} for epi in get_json_feed()['episodes'] if epi['quicktime']['url']]
80+
81+
finish_kwargs = {
82+
'sort_methods': [
83+
('UNSORTED', '%X'),
84+
('TITLE', '%X'),
85+
'DURATION',
86+
],
87+
}
88+
89+
return plugin.finish(items, **finish_kwargs)
90+
91+
92+
def run():
93+
plugin.run()

resources/tests/test_addon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_index(self):
4545
self.assertTrue(len(items) > 35)
4646
expected = {
4747
'info': {
48-
'plot': u'Vim\u2019s list feature can be used to reveal hidden characters, such as tabstops and newlines. In this episode, I demonstrate how to customise the appearance of these characters by tweaking the listchars setting. I go on to show how to make these invisible characters blend in with your colortheme.'},
48+
'plot': u'Vim\u2019s list feature can be used to reveal hidden characters, such as tabstops and newlines. In this episode, I demonstrate how to customise the appearance of these characters by tweaking the listchars setting. I go on to show how to make these invisible characters blend in with your colortheme.\n'},
4949
'is_playable': True,
5050
'label': u'#1 Show invisibles',
5151
'path': u'http://media.vimcasts.org/videos/1/show_invisibles.m4v',

0 commit comments

Comments
 (0)