Skip to content

Commit

Permalink
Add mirroring subs to TheWiz servers.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaTzil committed Oct 22, 2016
1 parent 7a013eb commit 1e4eeb3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<requires>
<import addon="xbmc.python" version="2.14.0"/>
<import addon="script.common.plugin.cache" version="2.5.5"/>
<import addon="script.module.requests" version="2.4.3"/>
</requires>
<extension point="xbmc.subtitle.module" library="service.py"/>
<extension point="xbmc.addon.metadata">
Expand Down
21 changes: 21 additions & 0 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import xbmcaddon
import xbmcgui
import xbmcplugin
from requests import post


__addon__ = xbmcaddon.Addon()
Expand Down Expand Up @@ -91,6 +92,23 @@ def get_params(string=""):

return param

def mirror_sub(id, filename, sub_file):
values = {}
values['id'] = id
values['versioname'] = filename
values['source'] = 'subscenter'
values['year'] = xbmc.getInfoLabel("VideoPlayer.Year")
values['season'] = str(xbmc.getInfoLabel("VideoPlayer.Season"))
values['episode'] = str(xbmc.getInfoLabel("VideoPlayer.Episode"))
values['imdb'] = str(xbmc.getInfoLabel("VideoPlayer.IMDBNumber"))
values['tvshow'] = normalizeString(xbmc.getInfoLabel("VideoPlayer.TVshowtitle"))
values['title'] = normalizeString(xbmc.getInfoLabel("VideoPlayer.OriginalTitle"))
values['file_original_path'] = urllib.unquote(unicode(xbmc.Player().getPlayingFile(), 'utf-8'))
url = 'http://subs.thewiz.info/send.php'
try:
post(url, files={'sub': open(sub_file, 'rb')}, data=values)
except:
pass

params = get_params()

Expand Down Expand Up @@ -156,8 +174,11 @@ def get_params(string=""):
subs = download(params["id"], params["language"], params["link"], params["filename"])
## we can return more than one subtitle for multi CD versions, for now we are still working out how to handle that in XBMC core
for sub in subs:
if params["language"] == 'he':
mirror_sub(params["id"], params["filename"], sub)
listitem = xbmcgui.ListItem(label=sub)
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=sub, listitem=listitem, isFolder=False)

elif params['action'] == 'clear_store':
clear_store()

Expand Down

0 comments on commit 1e4eeb3

Please sign in to comment.