Version 0.9.3
This commit is contained in:
1 parent
646008ed99
commit
0c83485f4e
5 files changed
+123
-20
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.video.movistarplus"
|
<addon id="plugin.video.movistarplus"
|
||||||
name="Movistar+"
|
name="Movistar+"
|
||||||
version="0.9.2"
|
version="0.9.3"
|
||||||
provider-name="Paco8">
|
provider-name="Paco8">
|
||||||
<requires>
|
<requires>
|
||||||
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
|
<!--- <import addon="xbmc.python" version="2.25.0"/> -->
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ import io
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
|
import shutil
|
||||||
|
import glob
|
||||||
|
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from .endpoints import endpoints
|
from .endpoints import endpoints
|
||||||
@@ -36,6 +39,7 @@ class Movistar(object):
|
|||||||
add_extra_info = True
|
add_extra_info = True
|
||||||
#dplayer = 'webplayer'
|
#dplayer = 'webplayer'
|
||||||
dplayer = 'android.tv'
|
dplayer = 'android.tv'
|
||||||
|
account_dir = 'account_1'
|
||||||
|
|
||||||
def __init__(self, config_directory, reuse_devices=False):
|
def __init__(self, config_directory, reuse_devices=False):
|
||||||
self.logged = False
|
self.logged = False
|
||||||
@@ -54,6 +58,27 @@ class Movistar(object):
|
|||||||
|
|
||||||
self.quality = 'HD' # or UHD
|
self.quality = 'HD' # or UHD
|
||||||
|
|
||||||
|
# Account dir
|
||||||
|
content = Movistar.load_file_if_exists(config_directory + 'account.txt')
|
||||||
|
if content: self.account_dir = content
|
||||||
|
LOG('account_dir: {}'.format(self.account_dir))
|
||||||
|
|
||||||
|
account_dir = os.path.join(config_directory, self.account_dir)
|
||||||
|
if not os.path.exists(account_dir):
|
||||||
|
os.makedirs(account_dir)
|
||||||
|
# Migrate data
|
||||||
|
if self.account_dir == 'account_1':
|
||||||
|
for ext in ['*.conf', '*.json', '*.key']:
|
||||||
|
for f in glob.glob(os.path.join(config_directory, ext)):
|
||||||
|
#LOG(f)
|
||||||
|
shutil.move(f, account_dir)
|
||||||
|
if os.path.exists(config_directory + 'cache'):
|
||||||
|
#LOG(config_directory + 'cache')
|
||||||
|
shutil.move(config_directory + 'cache', account_dir)
|
||||||
|
|
||||||
|
self.config_dir = config_directory
|
||||||
|
config_directory = account_dir + '/'
|
||||||
|
|
||||||
# Cache
|
# Cache
|
||||||
self.cache = Cache(config_directory)
|
self.cache = Cache(config_directory)
|
||||||
if not os.path.exists(config_directory + 'cache'):
|
if not os.path.exists(config_directory + 'cache'):
|
||||||
@@ -1217,13 +1242,11 @@ class Movistar(object):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def install_key_file(self, filename):
|
def install_key_file(self, filename):
|
||||||
import shutil
|
|
||||||
if sys.version_info[0] > 2:
|
if sys.version_info[0] > 2:
|
||||||
filename = bytes(filename, 'utf-8')
|
filename = bytes(filename, 'utf-8')
|
||||||
shutil.copyfile(filename, self.cache.config_directory + 'auth.key')
|
shutil.copyfile(filename, self.cache.config_directory + 'auth.key')
|
||||||
|
|
||||||
def export_key_file(self, filename):
|
def export_key_file(self, filename):
|
||||||
import shutil
|
|
||||||
if sys.version_info[0] > 2:
|
if sys.version_info[0] > 2:
|
||||||
filename = bytes(filename, 'utf-8')
|
filename = bytes(filename, 'utf-8')
|
||||||
if self.account['access_token']:
|
if self.account['access_token']:
|
||||||
@@ -1443,3 +1466,50 @@ class Movistar(object):
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def get_accounts(self):
|
||||||
|
accounts = []
|
||||||
|
for d in os.listdir(self.config_dir):
|
||||||
|
if os.path.isdir(os.path.join(self.config_dir, d)) and d.startswith("account_"):
|
||||||
|
account = {'id': d, 'name': d.replace('account_', 'Cuenta ')}
|
||||||
|
content = Movistar.load_file_if_exists(os.path.join(self.config_dir, d, 'account.json'))
|
||||||
|
if content:
|
||||||
|
data = json.loads(content)
|
||||||
|
login = data.get('login')
|
||||||
|
if login:
|
||||||
|
if '@' in login:
|
||||||
|
p1, p2 = login.split('@')
|
||||||
|
account['login'] = p1[:3] +'...@'+ p2
|
||||||
|
else:
|
||||||
|
account['login'] = login[:3]
|
||||||
|
accounts.append(account)
|
||||||
|
return accounts
|
||||||
|
|
||||||
|
def switch_account(self, name):
|
||||||
|
Movistar.save_file(self.config_dir + 'account.txt', name)
|
||||||
|
|
||||||
|
def create_new_account(self):
|
||||||
|
accounts = self.get_accounts()
|
||||||
|
name = None
|
||||||
|
n = 1
|
||||||
|
while True:
|
||||||
|
name = 'account_' + str(n)
|
||||||
|
if not any(account.get("id") == name for account in accounts):
|
||||||
|
break;
|
||||||
|
n += 1
|
||||||
|
if name:
|
||||||
|
os.makedirs(self.config_dir + name)
|
||||||
|
return name
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def load_file_if_exists(filename):
|
||||||
|
content = None
|
||||||
|
if os.path.exists(filename):
|
||||||
|
with io.open(filename, 'r', encoding='utf-8') as handle:
|
||||||
|
content = handle.read()
|
||||||
|
return content
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def save_file(filename, content):
|
||||||
|
with io.open(filename, 'w', encoding='utf-8') as handle:
|
||||||
|
handle.write(content)
|
||||||
+46
-13
@@ -6,10 +6,13 @@ from __future__ import unicode_literals, absolute_import, division
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
|
import io
|
||||||
|
import os.path
|
||||||
|
|
||||||
import xbmc
|
import xbmc
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import xbmcplugin
|
import xbmcplugin
|
||||||
|
import xbmcaddon
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
import urllib.request as urllib2
|
import urllib.request as urllib2
|
||||||
@@ -20,9 +23,6 @@ else:
|
|||||||
from urllib import urlencode, quote_plus
|
from urllib import urlencode, quote_plus
|
||||||
from urlparse import parse_qsl
|
from urlparse import parse_qsl
|
||||||
|
|
||||||
import xbmcaddon
|
|
||||||
import os.path
|
|
||||||
|
|
||||||
from .log import LOG
|
from .log import LOG
|
||||||
from .movistar import *
|
from .movistar import *
|
||||||
from .addon import *
|
from .addon import *
|
||||||
@@ -93,7 +93,10 @@ def play(params):
|
|||||||
else:
|
else:
|
||||||
url = d['url']
|
url = d['url']
|
||||||
|
|
||||||
proxy = m.cache.load_file('proxy.conf')
|
# Read the proxy address
|
||||||
|
proxy = Movistar.load_file_if_exists(os.path.join(profile_dir, 'proxy.txt'))
|
||||||
|
LOG('proxy address: {}'.format(proxy))
|
||||||
|
|
||||||
if addon.getSettingBool('manifest_modification') and proxy:
|
if addon.getSettingBool('manifest_modification') and proxy:
|
||||||
url = '{}/?manifest={}'.format(proxy, url)
|
url = '{}/?manifest={}'.format(proxy, url)
|
||||||
|
|
||||||
@@ -108,7 +111,10 @@ def play(params):
|
|||||||
manifest_headers = 'User-Agent=' + useragent
|
manifest_headers = 'User-Agent=' + useragent
|
||||||
|
|
||||||
if stype == 'tv':
|
if stype == 'tv':
|
||||||
cdn_token = m.get_cdntoken()
|
cdn_token = m.cache.load('cdn.conf')
|
||||||
|
if not cdn_token:
|
||||||
|
cdn_token = m.get_cdntoken()
|
||||||
|
m.cache.save_file('cdn.conf', cdn_token)
|
||||||
#LOG('cdn_token: {}'.format(cdn_token))
|
#LOG('cdn_token: {}'.format(cdn_token))
|
||||||
manifest_headers += '&x-tcdn-token=' + cdn_token
|
manifest_headers += '&x-tcdn-token=' + cdn_token
|
||||||
|
|
||||||
@@ -178,7 +184,7 @@ def play(params):
|
|||||||
#ttml.use_language_filter = False
|
#ttml.use_language_filter = False
|
||||||
subtype = ttml.subtitle_type()
|
subtype = ttml.subtitle_type()
|
||||||
|
|
||||||
subfolder = profile_dir + os.sep +'subtitles/'
|
subfolder = os.path.join(profile_dir, 'subtitles')
|
||||||
if not os.path.exists(subfolder):
|
if not os.path.exists(subfolder):
|
||||||
os.makedirs(subfolder)
|
os.makedirs(subfolder)
|
||||||
|
|
||||||
@@ -186,7 +192,7 @@ def play(params):
|
|||||||
LOG('sublist: {}'.format(sublist))
|
LOG('sublist: {}'.format(sublist))
|
||||||
subpaths = []
|
subpaths = []
|
||||||
for sub in sublist:
|
for sub in sublist:
|
||||||
filename = subfolder + sub['lang']
|
filename = os.path.join(subfolder, sub['lang'])
|
||||||
LOG('Converting {}'.format(sub['filename']))
|
LOG('Converting {}'.format(sub['filename']))
|
||||||
response = m.net.session.get(sub['url'], allow_redirects=True)
|
response = m.net.session.get(sub['url'], allow_redirects=True)
|
||||||
content = response.content
|
content = response.content
|
||||||
@@ -618,15 +624,40 @@ def export_key():
|
|||||||
if directory:
|
if directory:
|
||||||
m.export_key_file(directory + 'movistarplus.key')
|
m.export_key_file(directory + 'movistarplus.key')
|
||||||
|
|
||||||
def list_users():
|
def select_account(id, name):
|
||||||
open_folder(addon.getLocalizedString(30160)) # Change user
|
m.switch_account(id)
|
||||||
|
open_folder(name)
|
||||||
add_menu_option(addon.getLocalizedString(30183), get_url(action='login')) # Login with username
|
add_menu_option(addon.getLocalizedString(30183), get_url(action='login')) # Login with username
|
||||||
add_menu_option(addon.getLocalizedString(30181), get_url(action='login_with_key')) # Login with key
|
add_menu_option(addon.getLocalizedString(30181), get_url(action='login_with_key')) # Login with key
|
||||||
if os.path.exists(profile_dir + 'auth.key'):
|
if os.path.exists(os.path.join(m.cache.config_directory, 'auth.key')):
|
||||||
add_menu_option(addon.getLocalizedString(30184), get_url(action='export_key')) # Export key
|
add_menu_option(addon.getLocalizedString(30184), get_url(action='export_key')) # Export key
|
||||||
add_menu_option(addon.getLocalizedString(30150), get_url(action='logout')) # Close session
|
add_menu_option(addon.getLocalizedString(30150), get_url(action='logout')) # Close session
|
||||||
close_folder()
|
close_folder()
|
||||||
|
|
||||||
|
def list_accounts(params):
|
||||||
|
LOG('list_accounts: {}'.format(params))
|
||||||
|
|
||||||
|
if params.get('name') == 'new_account':
|
||||||
|
m.create_new_account()
|
||||||
|
|
||||||
|
accounts = m.get_accounts()
|
||||||
|
open_folder(addon.getLocalizedString(30160)) # Accounts
|
||||||
|
for account in accounts:
|
||||||
|
name = account['name']
|
||||||
|
login = account.get('login')
|
||||||
|
if login:
|
||||||
|
name += ' ({})'.format(login)
|
||||||
|
if account['id'] == m.account_dir:
|
||||||
|
display_name = '[B][COLOR blue]' + name + '[/COLOR][/B]'
|
||||||
|
else:
|
||||||
|
display_name = name
|
||||||
|
add_menu_option(display_name, get_url(action='select_account', id=account['id'], name=name))
|
||||||
|
add_menu_option(addon.getLocalizedString(30161), get_url(action='accounts', name='new_account')) # Add new
|
||||||
|
close_folder(cacheToDisc=False)
|
||||||
|
|
||||||
|
if params.get('name') == 'new_account':
|
||||||
|
xbmc.executebuiltin('Container.Update({},replace)'.format(xbmc.getInfoLabel('Container.FolderPath')))
|
||||||
|
|
||||||
def iptv(params):
|
def iptv(params):
|
||||||
LOG('iptv: params: {}'.format(params))
|
LOG('iptv: params: {}'.format(params))
|
||||||
if m.logged:
|
if m.logged:
|
||||||
@@ -702,8 +733,10 @@ def router(paramstring):
|
|||||||
login()
|
login()
|
||||||
elif params['action'] == 'export_key':
|
elif params['action'] == 'export_key':
|
||||||
export_key()
|
export_key()
|
||||||
elif params['action'] == 'user':
|
elif params['action'] == 'select_account':
|
||||||
list_users()
|
select_account(params['id'], params['name'])
|
||||||
|
elif params['action'] == 'accounts':
|
||||||
|
list_accounts(params)
|
||||||
elif params['action'] == 'logout':
|
elif params['action'] == 'logout':
|
||||||
logout()
|
logout()
|
||||||
elif params['action'] == 'epg':
|
elif params['action'] == 'epg':
|
||||||
@@ -759,7 +792,7 @@ def router(paramstring):
|
|||||||
elif m.expired_access_token:
|
elif m.expired_access_token:
|
||||||
show_notification(addon.getLocalizedString(30208))
|
show_notification(addon.getLocalizedString(30208))
|
||||||
|
|
||||||
add_menu_option(addon.getLocalizedString(30160), get_url(action='user'), icon='account.png') # Accounts
|
add_menu_option(addon.getLocalizedString(30160), get_url(action='accounts'), icon='account.png') # Accounts
|
||||||
add_menu_option(addon.getLocalizedString(30450), get_url(action='show_donation_dialog'), icon='qr.png') # Donation
|
add_menu_option(addon.getLocalizedString(30450), get_url(action='show_donation_dialog'), icon='qr.png') # Donation
|
||||||
close_folder(cacheToDisc=False)
|
close_folder(cacheToDisc=False)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<settings>
|
<settings>
|
||||||
<category label="30001">
|
<category label="30001">
|
||||||
<setting id="store_credentials" type="bool" label="30050" default="false"/>
|
<setting id="store_credentials" type="bool" label="30050" default="true"/>
|
||||||
<setting label="30017" type="bool" id="only_subscribed" default="true"/>
|
<setting label="30017" type="bool" id="only_subscribed" default="true"/>
|
||||||
<setting label="30020" type="bool" id="channels_with_epg" default="false"/>
|
<setting label="30020" type="bool" id="channels_with_epg" default="false"/>
|
||||||
<setting label="30021" type="bool" id="add_extra_info" default="false"/>
|
<setting label="30021" type="bool" id="add_extra_info" default="false"/>
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
<setting id="use_ttml2ssa" type="bool" label="$ADDON[script.module.ttml2ssa 32202]" default="false"/>
|
<setting id="use_ttml2ssa" type="bool" label="$ADDON[script.module.ttml2ssa 32202]" default="false"/>
|
||||||
<setting id="ssa_settings" type="action" label="$ADDON[script.module.ttml2ssa 32201]" option="close" action="Addon.OpenSettings(script.module.ttml2ssa)" visible="eq(-1,true)" subsetting="true"/>
|
<setting id="ssa_settings" type="action" label="$ADDON[script.module.ttml2ssa 32201]" option="close" action="Addon.OpenSettings(script.module.ttml2ssa)" visible="eq(-1,true)" subsetting="true"/>
|
||||||
<setting label="30019" type="action" id="is_settings" action="Addon.OpenSettings(inputstream.adaptive)" enable="System.HasAddon(inputstream.adaptive)" option="close"/>
|
<setting label="30019" type="action" id="is_settings" action="Addon.OpenSettings(inputstream.adaptive)" enable="System.HasAddon(inputstream.adaptive)" option="close"/>
|
||||||
<setting id="reuse_devices" type="bool" label="30023" default="false" visible="true"/>
|
<setting id="reuse_devices" type="bool" label="30023" default="false" visible="false"/>
|
||||||
<setting id="open_session" type="bool" label="30022" default="true" visible="true"/>
|
<setting id="open_session" type="bool" label="30022" default="true" visible="false"/>
|
||||||
<setting id="profile_id" type="text" label="Profile ID" default="Auto" visible="false"/>
|
<setting id="profile_id" type="text" label="Profile ID" default="Auto" visible="false"/>
|
||||||
<!--
|
<!--
|
||||||
<setting type="sep"/>
|
<setting type="sep"/>
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@ if __name__ == '__main__':
|
|||||||
proxy.start()
|
proxy.start()
|
||||||
LOG('proxy_address: {}'.format(proxy.proxy_address))
|
LOG('proxy_address: {}'.format(proxy.proxy_address))
|
||||||
cache = Cache(profile_dir)
|
cache = Cache(profile_dir)
|
||||||
cache.save_file('proxy.conf', proxy.proxy_address)
|
cache.save_file('proxy.txt', proxy.proxy_address)
|
||||||
|
|
||||||
if addon.getSettingBool('export_epg'):
|
if addon.getSettingBool('export_epg'):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in new issue
Block a user