Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some improvements (compatibility with python3 for Kodi Matrix, sorting channels by number), add some fix, some translations. #39

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ provider-name="primaeval, Chychy">
<import addon="script.module.requests" version="2.9.1" />
<import addon="script.module.chardet" />
<import addon="script.module.pytz" />
<import addon="script.module.kodi-six" />
</requires>
<extension point="xbmc.python.pluginsource" library="main.py">
<provides>video</provides>
Expand Down
5 changes: 3 additions & 2 deletions context.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import unicode_literals

import urllib

import xbmc
import xbmcgui
from kodi_six import xbmc, xbmcgui


def log(x):
Expand Down
5 changes: 3 additions & 2 deletions contextEPG.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import unicode_literals

import locale
import time
from datetime import datetime
import urllib

import xbmc
import xbmcgui
from kodi_six import xbmc, xbmcgui

DATE_FORMAT = "%Y-%m-%d %H:%M:00"

Expand Down
16 changes: 10 additions & 6 deletions default.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import xbmc,xbmcgui,xbmcaddon,xbmcvfs,xbmcplugin
from __future__ import unicode_literals
from kodi_six import xbmc,xbmcgui,xbmcaddon,xbmcvfs,xbmcplugin
import sys
import time,datetime
import sqlite3
import pytz
import tzlocal
import re
import urllib

try:
from urllib.parse import quote_plus
except ImportError:
from urllib import quote_plus

def log(x):
xbmc.log(repr(x),xbmc.LOGERROR)
Expand All @@ -24,7 +29,6 @@ def remove_formatting(label):
channel = sys.argv[1]
channel = channel.decode("utf8")
#channel = channel.encode("utf8")
#channel = urllib.quote_plus(channel)

title = sys.argv[2]
date = sys.argv[3]
Expand Down Expand Up @@ -56,9 +60,9 @@ def remove_formatting(label):
program_id = cursor.execute('SELECT uid FROM programmes WHERE channelid=? AND start=?',(channel_id,start_time)).fetchone()[0]
#log((channel_id, program_id, start_time))
if program_id:
channel = channel.encode("utf8")
channel = urllib.quote_plus(channel)
xbmc.executebuiltin("ActivateWindow(videos,plugin://plugin.video.iptv.recorder/broadcast/%s/%s,return)" % (program_id,channel))
channel_encoded = channel.encode("utf8")
channel_encoded = quote_plus(channel_encoded)
xbmc.executebuiltin("ActivateWindow(videos,plugin://plugin.video.iptv.recorder/broadcast/%s/%s,return)" % (program_id,channel_encoded))

except Exception as e:
#log(e)
Expand Down
24 changes: 20 additions & 4 deletions language.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
#! /usr/bin/python
from __future__ import unicode_literals

__strings = {}

if __name__ == "__main__":
import polib
import traceback
po = polib.pofile('resources/language/English/strings.po')

try:
import os
import re
import subprocess
r = subprocess.check_output(["grep", "-hnr", "_([\'\"]", "."])
strings = re.compile("_\([\"'](.*?)[\"']\)", re.IGNORECASE).findall(r)

strings = []
regex_to_found = re.compile("_\([\"'](.*?)[\"']\)", re.IGNORECASE)
for root, dirs, files in os.walk("."):
for file in files:
if file.endswith(".py"):
with open(os.path.join(root, file), "r", encoding="utf-8") as file_content:
for line in file_content:
strings_found = regex_to_found.findall(line)
if strings_found:
strings.extend(strings_found)

translated = [m.msgid.lower().replace("'", "\\'") for m in po]
missing = set([s for s in strings if s.lower() not in translated])
if missing:
ids_range = range(30000, 31000)
ids_reserved = [int(m.msgctxt[1:]) for m in po]
ids_available = [x for x in ids_range if x not in ids_reserved]
print "warning: missing translation for", missing
print("New text to translate found : %s" % missing)
for text in missing:
id = ids_available.pop(0)
entry = polib.POEntry(
Expand All @@ -28,6 +41,7 @@
po.append(entry)
po.save('resources/language/English/strings.po')
except:
traceback.print_exc()
pass

content = []
Expand All @@ -41,7 +55,7 @@
line = "__strings['{0}'] = {1}\n".format(m.msgid.lower().replace("'", "\\'"), m.msgctxt.replace('#', '').strip())
f.write(line)
else:
import xbmc, xbmcaddon
from kodi_six import xbmc, xbmcaddon
__language__ = xbmcaddon.Addon().getLocalizedString

def get_string(t):
Expand Down Expand Up @@ -143,3 +157,5 @@ def get_string(t):
__strings['add one time rule'] = 30087
__strings['categories'] = 30088
__strings['remind weekly'] = 30089
__strings['convert to mp4'] = 30090
__strings['all channels'] = 30091
Loading