PK J plugin.video.tv.team/PK
Z2J-ӯ plugin.video.tv.team/addon.xml
video
TvTeam TV Player
Provides access to TvTeam's Live TV and Archives
all
PK
v2J~b " plugin.video.tv.team/changelog.txt1.0.4
- Bug fix.
1.0.3
- It's possible now to change the streaming server.
1.0.2
- Bug fix.
1.0.1
- Bug fix.
1.0.0
- Initial release.PK
1J5M M plugin.video.tv.team/default.py#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import division
from collections import OrderedDict
from bs4 import BeautifulSoup, SoupStrainer
import xbmcplugin, xbmcgui, xbmcaddon
import sys, os
import re
import urllib, urllib2
import time, datetime
import string
import random
import simplejson as json
import hashlib
import base64
pluginhandle = int(sys.argv[1])
PLUGIN_ID = 'plugin.video.tv.team'
__addon__ = xbmcaddon.Addon(id=PLUGIN_ID)
__addonname__ = __addon__.getAddonInfo('name')
API_URL = 'https://tv.team/api/'
PROFILE_URL = 'https://tv.team/actions.php'
MEDIA_URL = 'special://home/addons/{0}/resources/media/'.format(PLUGIN_ID)
SESSION_TTL = 60*60*24
TOKEN_TTL = 60*60*12
show_images = (str(__addon__.getSetting('show_images')) == "true")
enable_sorting = (str(__addon__.getSetting('enable_sorting')) == "true")
####
def to_ascii (string):
translit_dict = {
u'\u0410' : 'A', u'\u0430' : 'a',
u'\u0411' : 'B', u'\u0431' : 'b',
u'\u0412' : 'V', u'\u0432' : 'v',
u'\u0413' : 'G', u'\u0433' : 'g',
u'\u0414' : 'D', u'\u0434' : 'd',
u'\u0415' : 'E', u'\u0435' : 'e',
u'\u0401' : 'Yo', u'\u0451' : 'yo',
u'\u0416' : 'Zh', u'\u0436' : 'zh',
u'\u0417' : 'Z', u'\u0437' : 'z',
u'\u0418' : 'I', u'\u0438' : 'i',
u'\u0419' : 'Y', u'\u0439' : 'y',
u'\u041a' : 'K', u'\u043a' : 'k',
u'\u041b' : 'L', u'\u043b' : 'l',
u'\u041c' : 'M', u'\u043c' : 'm',
u'\u041d' : 'N', u'\u043d' : 'n',
u'\u041e' : 'O', u'\u043e' : 'o',
u'\u041f' : 'P', u'\u043f' : 'p',
u'\u0420' : 'R', u'\u0440' : 'r',
u'\u0421' : 'S', u'\u0441' : 's',
u'\u0422' : 'T', u'\u0442' : 't',
u'\u0423' : 'U', u'\u0443' : 'u',
u'\u0424' : 'F', u'\u0444' : 'f',
u'\u0425' : 'H', u'\u0445' : 'h',
u'\u0426' : 'Ts', u'\u0446' : 'ts',
u'\u0427' : 'Ch', u'\u0447' : 'ch',
u'\u0428' : 'Sh', u'\u0448' : 'sh',
u'\u0429' : 'Sch', u'\u0449' : 'sch',
u'\u042a' : '', u'\u044a' : '',
u'\u042b' : 'Y', u'\u044b' : 'y',
u'\u042c' : '', u'\u044c' : '',
u'\u042d' : 'E', u'\u044d' : 'e',
u'\u042e' : 'Yu', u'\u044e' : 'yu',
u'\u042f' : 'Ya', u'\u044f' : 'ya',
}
new_string = []
for c in string:
new_string.append(translit_dict.setdefault(c, c))
return ''.join(new_string)
def getURL (url, cookie=None, data=None):
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0')
req.add_header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,q=0.8')
req.add_header('Accept-Language', 'en-US;q=0.8,en;q=0.6,ru;q=0.4,pl;q=0.2')
if cookie:
req.add_header('Cookie', cookie)
if data:
response = urllib2.urlopen(req, data, timeout=30)
else:
response = urllib2.urlopen(req, timeout=30)
result = response.read()
response.close()
return result
def getJSON (url):
data = getURL(url)
json_str = data.decode("utf8")
return json.loads(json_str, object_pairs_hook=OrderedDict)
####
def getProfileData():
sessionId_value = str(__addon__.getSetting('sessionId_value'))
COOKIE_val = "IPTVSESSID={0}".format(sessionId_value)
POST_params = urllib.urlencode({'action' : 'getUserProfileWindowContent'})
json_url = PROFILE_URL
data = getURL(json_url, COOKIE_val, POST_params)
data_str = data.decode("utf8")
json_str = re.findall(r'{"data":.*"}', data_str)
try:
json_response = json.loads(json_str[0], object_pairs_hook=OrderedDict)
except:
return False
userProfileData = dict({'status' : 1,
'userPasswd' : '',
'pornoPinCode': '',
'groupId' : '',
'groupId_label' : '',
'fsNumCon' : '',
'stNumCon': '',
'macAddress' : '',
'showPorno' : ''
})
if 'data' in json_response:
if 'userProfileWindow' in json_response['data']:
html_code = BeautifulSoup(json_response['data']['userProfileWindow'])
for input in html_code.find_all('input', {'id': 'profileUserPasswd'}):
if len(input["value"]) > 0:
userProfileData['userPasswd'] = input["value"]
else:
userProfileData['status'] = 0
for input in html_code.find_all('input', {'id': 'profilePornoPinCode'}):
if len(input["value"]) > 0:
userProfileData['pornoPinCode'] = input["value"]
else:
userProfileData['status'] = 0
for input in html_code.find_all('input', {'id': 'profileMacAddress'}):
userProfileData['macAddress'] = input["value"]
select = SoupStrainer('select', {'id': 'profileGroupId'})
html_code = BeautifulSoup(json_response['data']['userProfileWindow'], parse_only=select)
for option in html_code.find_all('option', {'selected': True}):
if len(option["value"]) and len(option.text) > 0:
userProfileData['groupId'] = option["value"]
userProfileData['groupId_label'] = option.text
else:
userProfileData['status'] = 0
select = SoupStrainer('select', {'id': 'showPorno'})
html_code = BeautifulSoup(json_response['data']['userProfileWindow'], parse_only=select)
for option in html_code.find_all('option', {'selected': True}):
if len(option["value"]):
userProfileData['showPorno'] = option["value"]
else:
userProfileData['status'] = 0
select = SoupStrainer('select', {'id': 'profileFsNumCon'})
html_code = BeautifulSoup(json_response['data']['userProfileWindow'], parse_only=select)
for option in html_code.find_all('option', {'selected': True}):
if len(option["value"]):
userProfileData['fsNumCon'] = option["value"]
else:
userProfileData['status'] = 0
select = SoupStrainer('select', {'id': 'profileStNumCon'})
html_code = BeautifulSoup(json_response['data']['userProfileWindow'], parse_only=select)
for option in html_code.find_all('option', {'selected': True}):
if len(option["value"]):
userProfileData['stNumCon'] = option["value"]
else:
userProfileData['status'] = 0
return userProfileData
def changeUserServer ():
sessionId_value = str(__addon__.getSetting('sessionId_value'))
serverFromKodi = str(__addon__.getSetting('server'))
profile_data = getProfileData()
if int(profile_data['status']) < 1: return False
new_server_id = re.sub(r'(\d)(\d)\.(tv)\.(team)', r'\2', serverFromKodi)
saveProfileData = dict({'action' : 'profileSave',
'userPasswd' : profile_data['userPasswd'],
'pornoPinCode': profile_data['pornoPinCode'],
'groupId' : new_server_id,
'fsNumCon' : profile_data['fsNumCon'],
'stNumCon' : profile_data['stNumCon'],
'macAddress' : profile_data['macAddress'],
'showPorno' : profile_data['showPorno']
})
COOKIE_val = "IPTVSESSID={0}".format(sessionId_value)
POST_params = urllib.urlencode(saveProfileData)
json_url = PROFILE_URL
data = getURL(json_url, COOKIE_val, POST_params)
data_str = data.decode("utf8")
json_str = re.findall(r'{"data":.*"}', data_str)
try:
json_response = json.loads(json_str[0], object_pairs_hook=OrderedDict)
except:
return False
__addon__.setSetting('sessionId_created', "0")
if 'data' in json_response:
if 'profileSaveInfoLayer' in json_response['data']:
save_response = re.findall(r'(.*)', json_response['data']['profileSaveInfoLayer'])
xbmcgui.Dialog().ok(__addonname__, save_response[0])
return True
return False
def checkUserServer ():
serverFromKodi = str(__addon__.getSetting('server'))
profile_data = getProfileData()
serverFromProfile = profile_data['groupId_label']
if int(profile_data['status']) < 1:
xbmcgui.Dialog().ok(__addonname__, 'Ошибка. Попробуйте позже.')
return -1
else:
if (serverFromKodi == serverFromProfile):
return 1
else:
return 0
def checkSessionId ():
userLogin = str(__addon__.getSetting('userLogin'))
userLogin_new = str(__addon__.getSetting('userLogin_new'))
userPasswd = str(__addon__.getSetting('userPasswd'))
userPasswd_new = str(__addon__.getSetting('userPasswd_new'))
sessionId_value = str(__addon__.getSetting('sessionId_value'))
sessionId_created = int(__addon__.getSetting('sessionId_created'))
if (len(re.findall(r'(?i)(? 0 and str(__addon__.getSetting('server')) or '01.tv.team')
if ((len(userLogin) < 1) or (len(userPasswd) < 1)) and ((len(userLogin_new) < 1) or (len(userPasswd_new) < 1)):
xbmcgui.Dialog().ok(__addonname__, "Введите свой пароль для входа в систему...")
new_userLogin = xbmcgui.Dialog().input('User name', type=xbmcgui.INPUT_ALPHANUM)
new_userPasswd = xbmcgui.Dialog().input('Password', type=xbmcgui.INPUT_PASSWORD)
server_list = ['01.tv.team', '02.tv.team']
select_index = xbmcgui.Dialog().select('Выберите свой сервер', server_list)
new_server = str(server_list[select_index])
__addon__.setSetting('userLogin', new_userLogin)
__addon__.setSetting('userLogin_new', new_userLogin)
__addon__.setSetting('userPasswd', new_userPasswd)
__addon__.setSetting('userPasswd_new', new_userPasswd)
__addon__.setSetting('server', new_server)
TVTEAM_init ()
else:
if checkSessionId() is True:
if checkUserServer() > 0:
if checkTokenId() is True:
TVTEAM_start()
else:
xbmcgui.Dialog().ok(__addonname__, "Ошибка токена. Попробуйте снова.")
__addon__.setSetting('sessionId_created', "0")
__addon__.setSetting('RandomToken_created', "0")
elif checkUserServer() == 0:
if changeUserServer() is True:
xbmcgui.Dialog().ok(__addonname__, 'Вы сменили сервер на %s. Нажмите ОК и подождите 5 минут пока идет активация сервера...' % server)
xbmc.sleep(1000*60*5)
else:
xbmcgui.Dialog().ok(__addonname__, 'Произошла ошибка при смене сервера!')
__addon__.setSetting('sessionId_created', "0")
__addon__.setSetting('RandomToken_created', "0")
else:
xbmcgui.Dialog().ok(__addonname__, "Проверьте свои данные в настройках!")
__addon__.setSetting('sessionId_created', "0")
__addon__.setSetting('RandomToken_created', "0")
def TVTEAM_start ():
name = '[COLOR yellow][B]ПРЯМОЙ ЭФИР[/B][/COLOR]'
item = xbmcgui.ListItem(name)
if show_images is True:
item.setArt({'thumb': MEDIA_URL + 'icon_1.png'})
url = sys.argv[0] + '?mode=Show_categories'
xbmcplugin.addDirectoryItem(pluginhandle, url, item, True)
name = '[COLOR white][B]АРХИВЫ С EPG[/B][/COLOR]'
item = xbmcgui.ListItem(name)
if show_images is True:
item.setArt({'thumb': MEDIA_URL + 'icon_2.png'})
url = sys.argv[0] + '?mode=Show_categories&for_archive=true'
xbmcplugin.addDirectoryItem(pluginhandle, url, item, True)
if show_images is True:
xbmc.executebuiltin('Container.SetViewMode(500)')
else:
xbmc.executebuiltin('Container.SetViewMode(501)')
xbmcplugin.endOfDirectory(pluginhandle, cacheToDisc=False)
####
def Show_categories (for_archive):
sessionId_value = str(__addon__.getSetting('sessionId_value'))
json_url = API_URL + "?apiAction=getFavouriteChannels,getUserChannels&resultType=tree&sessionId=%s" % sessionId_value;
try:
json_response = getJSON (json_url)
except:
xbmcplugin.endOfDirectory(pluginhandle)
return
if (int(json_response['status']) < 1):
xbmcplugin.endOfDirectory(pluginhandle)
return
categories = json_response['data']['userChannelsTree']
categories_sorted = (enable_sorting and sorted(categories, key=lambda k: to_ascii(k['groupName']).lower()) or categories)
all_count = 0
epg_count = 0
for category in categories_sorted:
category_count = len(category['channelsList'])
all_count += category_count
category_epg_count = 0
if category_count < 1: continue
if for_archive == 'true':
for channel in category['channelsList']:
if len(channel['curProgram']['prTitle']) > 0:
category_epg_count += 1
if category_epg_count < 1: continue
else: epg_count += category_epg_count
category_id = category['groupId']
category_name = unicode(category['groupName']).upper()
random_seed = hashlib.md5(str((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()) + str(random.randint(1, 999999))).hexdigest()
if for_archive != "true":
item_name = "[COLOR yellow][B]%s[/B][/COLOR] [I]([COLOR orange]%d[/COLOR])[/I]" % (category_name, category_count)
url = sys.argv[0] + '?mode=Show_channels'
url += '&cat_id=' + str(category_id)
url += '&seed=%s' % random_seed
else:
item_name = "[COLOR yellow][B]%s[/B][/COLOR] [I]([COLOR orange]%d[/COLOR])[/I]" % (category_name, category_epg_count)
url = sys.argv[0] + '?mode=Show_archive_channels'
url += '&cat_id=' + str(category_id)
url += '&seed=%s' % random_seed
item = xbmcgui.ListItem(item_name)
xbmcplugin.addDirectoryItem(pluginhandle, url, item, True)
if for_archive != "true":
item_name = "[COLOR red][B]ВСЕ КАНАЛЫ[/B][/COLOR] [I]([COLOR orange]%d[/COLOR])[/I]" % all_count
random_seed = hashlib.md5(str((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()) + str(random.randint(1, 999999))).hexdigest()
url = sys.argv[0] + '?mode=Show_channels'
url += '&show_all=true'
url += '&seed=%s' % random_seed
else:
item_name = "[COLOR red][B]ВСЕ КАНАЛЫ[/B][/COLOR] [I]([COLOR orange]%d[/COLOR])[/I]" % epg_count
random_seed = hashlib.md5(str((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()) + str(random.randint(1, 999999))).hexdigest()
url = sys.argv[0] + '?mode=Show_archive_channels'
url += '&show_all=true'
url += '&seed=%s' % random_seed
item = xbmcgui.ListItem(item_name)
xbmcplugin.addDirectoryItem(pluginhandle, url, item, True)
xbmc.executebuiltin('Container.SetViewMode(51)')
xbmcplugin.endOfDirectory(pluginhandle, cacheToDisc=False)
def Show_channels (cat_id, show_all):
sessionId_value = str(__addon__.getSetting('sessionId_value'))
json_url = API_URL + "?apiAction=getFavouriteChannels,getUserChannels&resultType=tree&sessionId=%s" % sessionId_value;
try:
json_response = getJSON (json_url)
except:
xbmcplugin.endOfDirectory(pluginhandle)
return
if (int(json_response['status']) < 1):
xbmcplugin.endOfDirectory(pluginhandle)
return
if show_all != "true":
for cat in json_response['data']['userChannelsTree']:
if int(cat['groupId']) == int(cat_id):
channels = cat["channelsList"]
channels_sorted = (enable_sorting and sorted(channels, key=lambda k: to_ascii(k['channelName']).lower()) or channels)
else:
channels = []
for cat in json_response['data']['userChannelsTree']:
for channel in cat['channelsList']:
channels.append(channel)
channels_sorted = (enable_sorting and sorted(channels, key=lambda k: to_ascii(k['channelName']).lower()) or channels)
for channel in channels_sorted:
random_seed = hashlib.md5(str((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()) + str(random.randint(1, 999999))).hexdigest()
channel_id = channel['channelId']
channel_name = unicode(channel['channelName']).upper()
channel_logo = channel['channelLogo']
channel_url = channel['liveLink']
channel_event_title = unicode(channel['curProgram']['prTitle']).upper()
if len(channel_event_title) > 0:
channel_event_start = datetime.datetime.fromtimestamp(time.mktime(time.strptime(channel['curProgram']['prStart'], "%d.%m.%Y %H:%M:%S"))) - datetime.timedelta(seconds=0)
channel_event_stop = datetime.datetime.fromtimestamp(time.mktime(time.strptime(channel['curProgram']['prStop'], "%d.%m.%Y %H:%M:%S"))) - datetime.timedelta(seconds=0)
channel_event_start_unixtime = int(time.mktime(channel_event_start.timetuple()))
channel_event_stop_unixtime = int(time.mktime(channel_event_stop.timetuple()))
channel_event_duration = channel_event_stop_unixtime - channel_event_start_unixtime
channel_event_progress = channel['curProgram']['%']
item_name = "[COLOR yellow][B]%s[/B][/COLOR] ([COLOR green]%s-%s[/COLOR] / [COLOR orange]%d%%[/COLOR] / [COLOR white]%s[/COLOR])" % (
channel_name,
channel_event_start.strftime('%H:%M'),
channel_event_stop.strftime('%H:%M'),
channel_event_progress,
channel_event_title)
else:
item_name = "[COLOR yellow][B]%s[/B][/COLOR]" % (channel_name)
url = sys.argv[0] + '?mode=Play_live_channel'
url += '&url=%s' % urllib.quote_plus(channel_url)
url += '&seed=%s' % random_seed
item = xbmcgui.ListItem(item_name)
if (show_images):
item.setArt({'thumb': channel_logo, 'clearlogo': channel_logo})
context_menu = []
context_menu.append(('[COLOR orange][B]Задать любое время[/B][/COLOR]','XBMC.RunPlugin(%s?mode=Invoke_time_picker&url=%s&icon=%s&name=%s)' % (
sys.argv[0],
urllib.quote_plus(channel_url),
urllib.quote_plus(channel_logo),
re.sub("=", "", base64.urlsafe_b64encode(channel_name.encode('utf-8')))
)))
if len(channel_event_title) > 0:
context_menu.append(('[COLOR red][B]Начать передачу сначала[/B][/COLOR]','XBMC.RunPlugin(%s?mode=Rewind_live_channel&url=%s&icon=%s&name=%s&unixtime=%d&duration=%d)' % (
sys.argv[0],
urllib.quote_plus(channel_url),
urllib.quote_plus(channel_logo),
re.sub("=", "", base64.urlsafe_b64encode(item_name.encode('utf-8'))),
channel_event_start_unixtime,
channel_event_duration
)))
item.addContextMenuItems(items=context_menu, replaceItems=True)
item.setInfo( type='video', infoLabels={'title': item_name, 'mediatype':'video'})
item.setProperty('IsPlayable', 'true')
xbmcplugin.addDirectoryItem(pluginhandle, url, item)
xbmc.executebuiltin('Container.SetViewMode(51)')
xbmcplugin.endOfDirectory(pluginhandle, cacheToDisc=False)
def Play_live_channel (url):
RandomToken_value = str(__addon__.getSetting('RandomToken_value'))
stream_url = url + "?token=" + RandomToken_value
item = xbmcgui.ListItem(path = stream_url)
xbmcplugin.setResolvedUrl(pluginhandle, True, item)
def Rewind_live_channel (url, icon, name, unixtime, duration):
RandomToken_value = str(__addon__.getSetting('RandomToken_value'))
archive_name = re.sub('( \[COLOR orange\].*\[/COLOR\] /)', '', name)
item = xbmcgui.ListItem(archive_name)
item.setInfo('video', {'Title': archive_name, 'mediatype':'video'})
if show_images is True:
item.setArt({'thumb': icon, 'clearlogo': icon})
archive_url = re.sub('(mono.m3u8)', 'index-%s-%s.m3u8' % (unixtime, duration), url)
stream_url = archive_url + "?token=" + RandomToken_value
TVTEAM_player = xbmc.Player()
TVTEAM_player.play(stream_url, item)
def Invoke_time_picker (url, icon, name):
RandomToken_value = str(__addon__.getSetting('RandomToken_value'))
input_date = xbmcgui.Dialog().numeric(1, "Введите дату [DD/MM/YYYY]").replace(' ', '')
if len(re.findall(r'/', input_date)) > 1:
input_date_split = filter(None, input_date.split("/"))
input_date = "/".join(map(lambda x: (len(x.strip())<2 and '0'+x.strip() or x), input_date_split))
input_time = xbmcgui.Dialog().numeric(2, "Введите время [HH:MM]")
if len(re.findall(r':', input_time)) > 0:
input_time_split = filter(None, input_time.split(":"))
input_time = ":".join(map(lambda x: (len(x.strip())<2 and '0'+x.strip() or x), input_time_split))
else:
return False
else:
return False
selected_time = datetime.datetime.fromtimestamp(time.mktime(time.strptime("{0} {1}".format(input_date, input_time), "%d/%m/%Y %H:%M"))) - datetime.timedelta(seconds=0)
selected_time_human = selected_time.strftime('%Y-%m-%d %H:%M')
unixtime = int(time.mktime(selected_time.timetuple()))
unix_now = int((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds())
duration = 3600
if (unixtime > unix_now):
xbmcgui.Dialog().notification(__addonname__, "Назад в будущее?", xbmcgui.NOTIFICATION_INFO, 2000)
return False
item_name = "{0} [COLOR white][[COLOR green]{1}[/COLOR]][/COLOR]".format(name, selected_time_human)
item = xbmcgui.ListItem(item_name)
item.setInfo('video', {'Title': item_name, 'mediatype':'video'})
if show_images is True:
item.setArt({'thumb': icon, 'clearlogo': icon})
archive_url = re.sub('(mono.m3u8)', 'index-%d-%d.m3u8' % (unixtime, duration), url)
stream_url = archive_url + "?token=" + RandomToken_value
TVTEAM_player = xbmc.Player()
TVTEAM_player.play(stream_url, item)
####
def Show_archive_channels (cat_id, show_all):
sessionId_value = str(__addon__.getSetting('sessionId_value'))
json_url = API_URL + "?apiAction=getFavouriteChannels,getUserChannels&resultType=tree&sessionId=%s" % sessionId_value;
try:
json_response = getJSON (json_url)
except:
xbmcplugin.endOfDirectory(pluginhandle)
return
if (int(json_response['status']) < 1):
xbmcplugin.endOfDirectory(pluginhandle)
return
if show_all == 'true':
channels = []
for cat in json_response['data']['userChannelsTree']:
for channel in cat['channelsList']:
if len(channel['curProgram']['prTitle']) > 0:
channels.append(channel)
channels_sorted = (enable_sorting and sorted(channels, key=lambda k: to_ascii(k['channelName']).lower()) or channels)
else:
for cat in json_response['data']['userChannelsTree']:
if int(cat['groupId']) == int(cat_id):
channels = cat["channelsList"]
channels_sorted = (enable_sorting and sorted(channels, key=lambda k: to_ascii(k['channelName']).lower()) or channels)
for channel in channels_sorted:
if len(channel['curProgram']['prTitle']) < 1: continue
channel_id = channel['channelId']
channel_name = unicode(channel['channelName']).upper()
channel_logo = channel['channelLogo']
channel_url = channel['liveLink']
item_name = u"[B][COLOR yellow]{0}[/COLOR][/B]".format(channel_name)
item = xbmcgui.ListItem(item_name)
context_menu = []
context_menu.append(('[COLOR orange][B]Задать любое время[/B][/COLOR]','XBMC.RunPlugin(%s?mode=Invoke_time_picker&url=%s&icon=%s&name=%s)' % (
sys.argv[0],
urllib.quote_plus(channel_url),
urllib.quote_plus(channel_logo),
re.sub("=", "", base64.urlsafe_b64encode(channel_name.encode('utf-8')))
)))
item.addContextMenuItems(items=context_menu, replaceItems=True)
random_seed = hashlib.md5(str((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()) + str(random.randint(1, 999999))).hexdigest()
url = sys.argv[0] + '?mode=Display_EPG'
url += '&chid=%s' % channel_id
url += '&icon=%s' % urllib.quote_plus(channel_logo)
url += '&seed=%s' % random_seed
if (show_images):
item.setArt({'thumb': channel_logo, 'clearlogo': channel_logo})
xbmcplugin.addDirectoryItem(pluginhandle, url, item, True)
if show_images is True:
xbmc.executebuiltin('Container.SetViewMode(500)')
else:
xbmc.executebuiltin('Container.SetViewMode(51)')
xbmcplugin.endOfDirectory(pluginhandle, cacheToDisc=False)
def Display_EPG (chid, icon):
sessionId_value = str(__addon__.getSetting('sessionId_value'))
json_url = API_URL + "?apiAction=getTvProgram&sessionId=%s&channelId=%s" % (sessionId_value, chid);
try:
json_response = getJSON (json_url)
except:
xbmcplugin.endOfDirectory(pluginhandle)
return
if int(json_response['status']) < 1 or len(json_response['data']['tvProgram']) < 1:
xbmcplugin.endOfDirectory(pluginhandle)
return
full_epg = json_response['data']['tvProgram']
dates_label = []
dates_tvteam = []
for epg in full_epg:
if epg['timeMarker'] == 'future': continue
date_obj = datetime.datetime.fromtimestamp(time.mktime(time.strptime(epg['prStart'], "%d.%m.%Y %H:%M:%S"))) - datetime.timedelta(seconds=0)
date_label = date_obj.strftime('%Y-%m-%d')
date_tvteam = date_obj.strftime('%d.%m.%Y')
if date_label not in dates_label:
dates_label.append(date_label)
dates_tvteam.append(date_tvteam)
reversed_dates_label = dates_label[::-1]
reversed_dates_tvteam = dates_tvteam[::-1]
select_index = xbmcgui.Dialog().select('Выберите дату', reversed_dates_label)
select_value = str(reversed_dates_tvteam[select_index])
if select_index < 0: return
xbmc.sleep(500)
for epg in full_epg:
if select_value in epg['prStart']:
epg_title = unicode(epg['prTitle']).upper()
epg_start_unixtime = int(epg['prStartSec'])
epg_stop_unixtime = int(epg['prStopSec'])
epg_start = datetime.datetime.fromtimestamp(epg_start_unixtime) - datetime.timedelta(seconds=0)
epg_stop = datetime.datetime.fromtimestamp(epg_stop_unixtime) - datetime.timedelta(seconds=0)
epg_duration = epg_stop_unixtime - epg_start_unixtime
stream_url = epg['streamLink']
if epg['timeMarker'] == u"record":
item_name = u"[I][[COLOR green]{0} - {1}[/COLOR]][/I] - [B][COLOR yellow]{2}[/COLOR][/B]".format(
epg_start.strftime("%Y-%m-%d %H:%M"),
epg_stop.strftime("%H:%M"),
epg_title)
elif epg['timeMarker'] == u"live":
item_name = u"[I][[COLOR green]{0} - {1}[/COLOR]][/I] - [B][COLOR red]{2}[/COLOR][/B]".format(
epg_start.strftime("%Y-%m-%d %H:%M"),
epg_stop.strftime("%H:%M"),
epg_title)
else:
item_name = u"[I][[COLOR green]{0} - {1}[/COLOR]][/I] - [COLOR white]{2}[/COLOR]".format(
epg_start.strftime("%Y-%m-%d %H:%M"),
epg_stop.strftime("%H:%M"),
epg_title)
item = xbmcgui.ListItem(item_name)
random_seed = hashlib.md5(str((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds()) + str(random.randint(1, 999999))).hexdigest()
url = sys.argv[0] + '?mode=Play_archive_channel'
url += '&url=%s' % urllib.quote_plus(stream_url)
url += '&icon=%s' % urllib.quote_plus(icon)
url += '&name=%s' % re.sub("=", "", base64.urlsafe_b64encode(item_name.encode('utf-8')))
url += '&unixtime=%d' % unixtime
url += '&duration=%d' % epg_duration
url += '&seed=%s' % random_seed
if len(stream_url) > 1:
item.setProperty('IsPlayable', 'true')
else:
item.setProperty('IsPlayable', 'false')
if (show_images):
item.setArt({'thumb': icon, 'clearlogo': icon})
xbmcplugin.addDirectoryItem(pluginhandle, url, item)
xbmc.executebuiltin('Container.SetViewMode(51)')
xbmcplugin.endOfDirectory(pluginhandle, cacheToDisc=True)
def Play_archive_channel (url, icon, name, unixtime, duration):
if len(url) < 1:
xbmcgui.Dialog().notification(__addonname__, "Запись етой программы не найдена", xbmcgui.NOTIFICATION_INFO, 2000)
return False
else:
RandomToken_value = str(__addon__.getSetting('RandomToken_value'))
item = xbmcgui.ListItem(name)
item.setInfo('video', {'Title': name, 'mediatype':'video'})
if show_images is True:
item.setArt({'thumb': icon, 'clearlogo': icon})
archive_url = re.sub(r'index-(\d+)-(now).m3u8', r'index-\1-{0}.m3u8'.format(duration), url)
stream_url = archive_url + "?token=" + RandomToken_value
item = xbmcgui.ListItem(path = stream_url)
xbmcplugin.setResolvedUrl(pluginhandle, True, item)
####
def get_params():
param=[]
paramstring=sys.argv[2]
if len(paramstring)>=2:
params=sys.argv[2]
cleanedparams=params.replace('?','')
if (params[len(params)-1]=='/'):
params=params[0:len(params)-2]
pairsofparams=cleanedparams.split('&')
param={}
for i in range(len(pairsofparams)):
splitparams={}
splitparams=pairsofparams[i].split('=')
if (len(splitparams))==2:
param[splitparams[0]]=splitparams[1]
return param
params=get_params()
mode=None
url=''
icon=''
chid=''
cat_id=''
date=''
name=''
unixtime=0
duration=0
show_all=""
for_archive=''
try:
mode=params['mode']
except: pass
try:
url=urllib.unquote_plus(params['url'])
except: pass
try:
icon=urllib.unquote_plus(params['icon'])
except: pass
try:
chid=params['chid']
except: pass
try:
cat_id=params['cat_id']
except: pass
try:
date=params['date']
except: pass
try:
name=base64.urlsafe_b64decode(params['name'] + '=' * (4 - len(params['name']) % 4))
except: pass
try:
unixtime=params['unixtime']
except: pass
try:
duration=params['duration']
except: pass
try:
show_all=params['show_all']
except: pass
try:
for_archive=params['for_archive']
except: pass
####
if mode == 'TVTEAM_start': TVTEAM_start()
elif mode == 'Show_categories': Show_categories(for_archive)
elif mode == 'Show_channels': Show_channels(cat_id, show_all)
elif mode == 'Play_live_channel': Play_live_channel(url)
elif mode == 'Rewind_live_channel': Rewind_live_channel(url, icon, name, unixtime, duration)
elif mode == 'Invoke_time_picker': Invoke_time_picker(url, icon, name)
elif mode == 'Show_archive_channels': Show_archive_channels(cat_id, show_all)
elif mode == 'Play_archive_channel': Play_archive_channel(url, icon, name, unixtime, duration)
elif mode == 'Display_EPG': Display_EPG(chid, icon)
elif mode == '' or mode == None: TVTEAM_init()
PK
JDg g plugin.video.tv.team/icon.pngPNG
IHDR ?1 tEXtSoftware Adobe ImageReadyqe<