Skip to content

Commit

Permalink
new file: .gitattributes
Browse files Browse the repository at this point in the history
	new file:   .gitignore
	new file:   LICENSE.txt
	new file:   LICENSE_IMAGES.txt
	new file:   _pack.cmd
	new file:   addon.xml
	new file:   changelog.txt
	new file:   common.py
	new file:   icon.png
	new file:   o2tvgo.py
	new file:   playlist.py
	new file:   requirements.txt
	new file:   resources/language/resource.language.cs_CZ/strings.xml
	new file:   resources/language/resource.language.en_GB/strings.xml
	new file:   resources/language/resource.language.sk_SK/strings.xml
	new file:   resources/settings.xml
	new file:   service.py
  • Loading branch information
cisarikj committed May 10, 2019
1 parent cc8017c commit fc7eef7
Show file tree
Hide file tree
Showing 17 changed files with 1,776 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto


# Basic .gitattributes for a python repo.

# Source files
# ============
*.pxd text
*.py text
*.py3 text
*.pyw text
*.pyx text

# Binary files
# ============
*.db binary
*.p binary
*.pkl binary
*.pyc binary
*.pyd binary
*.pyo binary

# Note: .db, .p, and .pkl files are associated
# with the python modules ``pickle``, ``dbm.*``,
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
# (among others).
142 changes: 142 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
config.py
streamer.sh
streamer.sh.sample
device_id
o2tv.generic.m3u8
o2tv.playlist.m3u8
_sonar.cmd
.scannerwork

.idea

# Created by https://www.gitignore.io/api/python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

### Python Patch ###
.venv/

### Python.VirtualEnv Stack ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
[Bb]in
[Ii]nclude
[Ll]ib
[Ll]ib64
[Ll]ocal
[Ss]cripts
pyvenv.cfg
pip-selfcheck.json


# End of https://www.gitignore.io/api/python
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2014 Štěpán Ort & 2018 Jiří Roubal

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

10 changes: 10 additions & 0 deletions LICENSE_IMAGES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-----------------------------------------------------------------------------------------------------------

icon.png

By: O2
Source:
* http://a391.phobos.apple.com/us/r30/Purple3/v4/7c/e4/c5/7ce4c5a4-7ecf-4d8c-7e85-effbb6c437c2/mzl.ynoelino.png
Edited by: Štěpán Ort & Jiří Roubal

-----------------------------------------------------------------------------------------------------------
7 changes: 7 additions & 0 deletions _pack.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@echo off
set zip="c:\program files\7-zip\7z.exe"
if exist service.playlist.o2tv.zip del service.playlist.o2tv.zip
%zip% a service.playlist.o2tv.zip ..\o2tvkodi\ -r -x!*.pyc -x!.idea -x!.git -x!device_id -x!playlist.log -x!o2tv.generic.m3u8 -x!o2tv.playlist.m3u8 -x!streamer.sh*
%zip% rn service.playlist.o2tv.zip o2tvkodi\ service.playlist.o2tv\
%zip% d service.playlist.o2tv.zip service.playlist.o2tv\config.py
%zip% rn service.playlist.o2tv.zip service.playlist.o2tv\config.py.sample service.playlist.o2tv\config.py
22 changes: 22 additions & 0 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.playlist.orangetv" name="Playlist OrangeTV" version="0.1" provider-name="JiRo, úprava addon Štěpána Orta, upravený pre OrangeTV">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.requests" version="2.7.0"/>
</requires>
<extension library="service.py" point="xbmc.service">
<provides>service</provides>
</extension>
<extension point="xbmc.addon.metadata">
<news>
2019-05-08 [0.1]
First release for OrangeTV

</news>
<summary>Playlist OrangeTV</summary>
<description>Plugin to download of playlist from OrangeTV Slovakia broadcasting service</description>
<description lang="cs">Plugin pro stažení playlistu ze služby OrangeTV Slovensko</description>
<description lang="sk">Plugin pre stiahnutie playlistu zo služby OrangeTV Slovensko</description>
<platform>all</platform>
</extension>
</addon>
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
2019-05-08 [0.1]
First release.

134 changes: 134 additions & 0 deletions common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
import random
import stat
import unicodedata
from uuid import getnode as get_mac

import config as cfg

version = '0.1'
date = '2019-05-08'
pipe = 'pipe://'
default_group_name = "OrangeTV"
marhy = 'https://marhycz.github.io/picons/640/', 'https://marhycz.github.io/picons/1024/'
log_file = os.path.join(cfg.playlist_path, 'playlist.log')
id_file = os.path.join(cfg.playlist_path, 'device_id')
authent_error = 'AuthenticationError'
toomany_error = 'TooManyDevicesError'
nopurch_error = 'NoPurchasedServiceError'


def device_id():
mac = get_mac()
hexed = hex((mac * 7919) % (2 ** 64))
return ('0000000000000000' + hexed[2:-1])[16:]


def random_hex16():
return ''.join([random.choice('0123456789abcdef') for x in range(16)])


def to_string(text):
if type(text).__name__ == 'unicode':
output = text.encode('utf-8')
else:
output = str(text)
return output


def logo_name(channel):
channel = unicode(channel, 'utf-8')
channel = unicodedata.normalize('NFKD', channel)
channel = channel.lower()
name = ''
for char in channel:
if not unicodedata.combining(char) and (char.isalpha() or char.isdigit()):
name += char
return name


def add_param(param, value, cond):
item = ''
if cond:
item = ' %s="%s"' % (param, str(value))
return item


def write_file(content, name, log=None):
if not log is None:
log("Saving file: " + name)
f = open(name, 'w')
f.write(content)
f.close()


def try_exec(name):
f = name
try:
sts = os.stat(f)
if not (sts.st_mode & stat.S_IEXEC):
os.chmod(f, sts.st_mode | stat.S_IEXEC)
except:
pass


def write_streamer(streamer_file, playlist_file, ffmpeg_cmd, log=None):
streamer_code = '#! /bin/bash\n' + \
'source=$*\n' + \
'tempplaylist=$(mktemp -u)".m3u8"\n' + \
'stream=$(grep -A 1 "${source}$" ' + playlist_file + \
' | head -n 2 | tail -n 1)\n' + \
'wget -qO ${tempplaylist} ${stream}\n' + \
'streamcount=$(cat ${tempplaylist} | grep -Eo "(http|https)://[\da-z./?A-Z0-9\D=_-]*" | wc -l)\n' + \
'streamcount=$((streamcount-1))\n' + \
'if [ "$streamcount" = "-1" ]; then streamcount=0; fi\n' + \
ffmpeg_cmd + ' -protocol_whitelist file,http,https,tcp,tls -fflags +genpts ' + \
'-loglevel fatal -i ${tempplaylist} -probesize 32 -reconnect_at_eof 1 -reconnect_streamed 1 ' + \
'-c copy -map p:${streamcount}? -f mpegts -tune zerolatency -bsf:v h264_mp4toannexb,dump_extra ' + \
'-mpegts_service_type digital_tv pipe:1\n'

if not log is None:
log('Saving Streamer: ' + streamer_file)
write_file(streamer_code, streamer_file + '.sample')
# _to_file(c.streamer_code, os.path.join(cfg.playlist_path, cfg.playlist_streamer + '.sample'))
try_exec(streamer_file + '.sample')
write_file(streamer_code, streamer_file)
try_exec(streamer_file)


def build_channel_lines(channel, channel_logo, logoname, streamer, group, playlist_type, channel_epg_name, channel_epg_id, channel_group):
name = channel.name
logo = to_string(channel.logo_url)
url = to_string(channel.url())
epgname = name
epgid = name
r = ""
# číslo programu v epg
# viz https://www.o2.cz/file_conver/174210/_025_J411544_Razeni_televiznich_programu_O2_TV_03_2018.pdf
channel_weight = to_string(channel.weight)
# logo v mistnim souboru - kdyz soubor neexistuje, tak pouzit url
if (channel_logo > 1) and (logoname != ""):
logo = logoname
if playlist_type == 1:
r += '#EXTINF:-1'
r += add_param('tvg-name', epgname, channel_epg_name != 0)
r += add_param('tvg-id', epgid, channel_epg_id != 0)
r += add_param('tvg-logo', logo, channel_logo != 0)
r += add_param('tvg-chno', channel_weight, channel_epg_id != 0)
r += add_param('group-titles', group, channel_group != 0)
r += ', %s\n%s\n' % (name, url)
if (playlist_type == 2) or (playlist_type == 3):
r += '#EXTINF:-1'
r += add_param('tvg-id', epgid, channel_epg_id != 0)
r += add_param('tvg-logo', logo, channel_logo != 0)
r += add_param('tvg-chno', channel_weight, channel_epg_id != 0)
r += add_param('group-titles', group, channel_group != 0)
r += ', %s\n' % name
if playlist_type == 2:
r += '%s\n' % url
if playlist_type == 3:
r += '%s %s\n' % (streamer, name)
return r
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit fc7eef7

Please sign in to comment.