2014-03-02, 12:14
# Embedded file name: /Users/thevakaran/Library/Application Support/XBMC/addons/plugin.video.IPTV.Express/system_osx.py
import utils, httplib2, socks, httplib, logging, time
import urllib, re
import xbmc, xbmcgui
import time
import urllib2
import shutil
import urlparse
import os
import os.path
import hashlib
import xbmcplugin
import xbmcaddon
import xbmcvfs
import string, sys, traceback, unicodedata, cookielib
import xml.dom.minidom, base64
from BeautifulSoup import BeautifulStoneSoup, BeautifulSoup, BeautifulSOAP
try:
import json
except:
import simplejson as json
class iptvex:
PLUGIN_MODE_PLAY_YT_VIDEO = 20
PLUGIN_MODE_QUERY_DB = 30
PLUGIN_MODE_QUERY_YT = 40
PLUGIN_MODE_BUILD_YT_USER = 50
PLUGIN_MODE_BUILD_YT_FAV = 60
PLUGIN_MODE_PLAY_PLAYLIST = 80
PLUGIN_MODE_PLAY_SLIDESHOW = 90
PLUGIN_MODE_OPEN_SETTINGS = 100
PLUGIN_MODE_PLAY_STREAM = 110
PLUGIN_MODE_PLAY_4SHARED = 120
PLUGIN_MODE_QUERY_DM = 130
PLUGIN_MODE_BUILD_DM_USER = 140
PLUGIN_MODE_GET_USERINFO = 150
PLUGIN_MODE_DOWNLOAD = 160
PLUGIN_MODE_QUERY = 170
PLUGIN_MODE_OPEN_DOWNLOADS = 180
PLUGIN_MODE_DOWNLOAD_ALL = 190
PLUGIN_MODE_PLAY_DESISTREAM = 200
PLUGIN_MODE_SHARE_EMAIL = 210
PLUGIN_MODE_PLAY_VUXMLSTREAM = 220
PLUGIN_MODE_PLAY_DAGSTREAM = 230
PLUGIN_MODE_OPEN_PLUGIN = 240
PLUGIN_MODE_PLAY_EBOUND = 250
PLUGIN_MODE_PLAY_URLRESOLVER = 260
PLUGIN_MODE_PLAY_YUPP = 270
PLUGIN_MODE_PLAY_BILLIONUPLOADS = 280
PLUGIN_MODE_PLAY_NOVAMOV = 290
PLUGIN_MODE_PLAY_IPTVEXPRESS = 300
PLUGIN_MODE_VOD = 500
PLUGIN_MODE_VOD2 = 510
def __init__(self):
self.os = str(self.get_os())
if self.os != 'OSX':
from sys import exit
self.message('Wrong device', 'ERROR')
exit()
self.base_url = 'https://iptvexpress.com'
self.plugin_ver = '3.0.0'
self.plugin_name = 'plugin.video.IPTV.Express'
self.addon = xbmcaddon.Addon(self.plugin_name)
self.profile = xbmc.translatePath(self.addon.getAddonInfo('profile'))
self.__settings__ = xbmcaddon.Addon(id=self.plugin_name)
self.home = self.__settings__.getAddonInfo('path')
self.favorites = xbmc.translatePath(os.path.join(self.profile, 'favorites'))
self.REV = xbmc.translatePath(os.path.join(self.profile, 'list_revision'))
self.icon = xbmc.translatePath(os.path.join(self.home, 'icon.png'))
self.fanart = xbmc.translatePath(os.path.join(self.home, 'fanart.jpg'))
self.source_file = xbmc.translatePath(os.path.join(self.profile, 'source_file'))
if os.path.exists(self.favorites) == True:
self.FAV = open(self.favorites).read()
if os.path.exists(self.source_file) == True:
self.SOURCES = open(self.source_file).read()
self.__scriptname__ = 'IPTV.Express'
self.__scriptid__ = self.plugin_name
self.__addoninfo__ = utils.get_addoninfo(self.__scriptid__)
self.__addon__ = self.__addoninfo__['addon']
self.__settings__ = xbmcaddon.Addon(id=self.__scriptid__)
self.DIR_USERDATA = xbmc.translatePath(self.__addoninfo__['profile'])
self.SUBTITLES_DIR = os.path.join(self.DIR_USERDATA, 'Subtitles')
self.IMAGE_DIR = os.path.join(self.DIR_USERDATA, 'Images')
if not os.path.isdir(self.DIR_USERDATA):
os.makedirs(self.DIR_USERDATA)
if not os.path.isdir(self.SUBTITLES_DIR):
os.makedirs(self.SUBTITLES_DIR)
if not os.path.isdir(self.IMAGE_DIR):
os.makedirs(self.IMAGE_DIR)
self.security_url = 'id=' + self.encid(self.serid()) + '&id2=' + self.macid() + '&env=' + self.os
def getSources(self):
file_path = os.path.dirname(__file__)
if file_path != '':
os.chdir(file_path)
if os.path.exists(self.favorites) == True:
self.addDir('Favorites', 'url', 4, xbmc.translatePath(os.path.join(self.home, 'resources', 'favorites.png')), self.fanart, '', '', '', False)
cache_url = self.base_url + '/secured/fetchdata.php?' + self.security_url + '&source=true'
sources = json.loads(self.cache(cache_url))
if len(sources) > 0:
for i in sources:
self.addDir(i[0], i[1], 1, i[2], self.fanart, '', '', '')
else:
if os.path.exists(self.favorites):
os.remove(self.favorites)
self.message(self.cache(self.base_url + '/secured/status.php?' + self.security_url), self.serid())
def get_os(self):
try:
xbmc_os = os.environ.get('OS')
except:
xbmc_os = 'unknown'
return xbmc_os.replace(' ', '')
def getVOD(self, url = None):
if '127.0.0.1' in url:
url = url.replace('127.0.0.1', 'iptvexpress.com')
elif '127.0.0.2' in url:
url = url.replace('127.0.0.2', 'iptvexpress.com')
sources = json.loads(self.cache(url + '&' + self.security_url))
for i in sources:
self.addDir(i[0], i[1], 1, i[2], self.fanart, '', '', '')
def encid(self, no):
enc = hashlib.md5(no).hexdigest()
return enc
def Download(self, url, dest):
output = open(dest, 'wb')
output.write(self.cache(url))
output.close()
def message(self, msg, title = 'IPTV Express - Activation Code'):
dialog = xbmcgui.Dialog()
dialog.ok(title, msg)
def macSerial(self):
from ctypes import *
from ctypes import util
iokit = cdll.LoadLibrary(util.find_library('IOKit'))
cf = cdll.LoadLibrary(util.find_library('CoreFoundation'))
cf.CFStringCreateWithCString.argtypes = [c_void_p, c_char_p, c_int32]
cf.CFStringCreateWithCString.restype = c_void_p
cf.CFStringGetCStringPtr.argtypes = [c_void_p, c_uint32]
cf.CFStringGetCStringPtr.restype = c_char_p
kCFAllocatorDefault = c_void_p.in_dll(cf, 'kCFAllocatorDefault')
kCFStringEncodingMacRoman = 0
kIOMasterPortDefault = c_void_p.in_dll(iokit, 'kIOMasterPortDefault')
kIOPlatformSerialNumberKey = 'IOPlatformSerialNumber'.encode('mac_roman')
iokit.IOServiceMatching.restype = c_void_p
iokit.IOServiceGetMatchingService.argtypes = [c_void_p, c_void_p]
iokit.IOServiceGetMatchingService.restype = c_void_p
iokit.IORegistryEntryCreateCFProperty.argtypes = [c_void_p,
c_void_p,
c_void_p,
c_uint32]
iokit.IORegistryEntryCreateCFProperty.restype = c_void_p
iokit.IOObjectRelease.argtypes = [c_void_p]
SERIAL = None
if SERIAL is None:
platformExpert = iokit.IOServiceGetMatchingService(kIOMasterPortDefault, iokit.IOServiceMatching('IOPlatformExpertDevice'))
if platformExpert:
key = cf.CFStringCreateWithCString(kCFAllocatorDefault, kIOPlatformSerialNumberKey, kCFStringEncodingMacRoman)
serialNumberAsCFString = iokit.IORegistryEntryCreateCFProperty(platformExpert, key, kCFAllocatorDefault, 0)
if serialNumberAsCFString:
SERIAL = cf.CFStringGetCStringPtr(serialNumberAsCFString, 0)
iokit.IOObjectRelease(platformExpert)
return SERIAL
def getSoup(self, url):
if url.startswith('http://') or url.startswith('https://'):
try:
if 'php?' in url or 'xml?' in url:
url += '&' + self.security_url
else:
url += '?' + self.security_url
data = self.cache(url)
except urllib2.URLError as e:
if hasattr(e, 'code'):
xbmc.executebuiltin('XBMC.Notification(IPTV Express,We failed with error code - ' + str(e.code) + ',10000,' + self.icon + ')')
elif hasattr(e, 'reason'):
xbmc.executebuiltin('XBMC.Notification(IPTV Express,We failed to reach a server. - ' + str(e.reason) + ',10000,' + self.icon + ')')
elif xbmcvfs.exists(url):
if url.startswith('smb://'):
copy = xbmcvfs.copy(url, xbmc.translatePath(os.path.join(self.profile, 'temp', 'sorce_temp.txt')))
if copy:
data = open(xbmc.translatePath(os.path.join(self.profile, 'temp', 'sorce_temp.txt')), 'r').read()
xbmcvfs.delete(xbmc.translatePath(os.path.join(self.profile, 'temp', 'sorce_temp.txt')))
else:
data = open(url, 'r').read()
else:
return
soup = BeautifulSOAP(data, convertEntities=BeautifulStoneSoup.XML_ENTITIES)
return soup
def getData(self, url, fanart):
soup = self.getSoup(url)
if len(soup('channels')):
channels = soup('channel')
for channel in channels:
name = channel('name')[0].string
thumbnail = channel('thumbnail')[0].string
if thumbnail == None:
thumbnail = ''
try:
if not channel('fanart'):
if self.__settings__.getSetting('use_thumb') == 'true':
fanArt = thumbnail
else:
fanArt = fanart
else:
fanArt = channel('fanart')[0].string
if fanArt == None:
raise
except:
fanArt = fanart
try:
desc = channel('info')[0].string
if desc == None:
raise
except:
desc = ''
try:
genre = channel('genre')[0].string
if genre == None:
raise
except:
genre = ''
try:
date = channel('date')[0].string
if date == None:
raise
except:
date = ''
try:
self.addDir(name.encode('utf-8', 'ignore'), url, 2, thumbnail, fanArt, desc, genre, date)
except:
print 'nothing to say........'
else:
self.getItems(soup('item'), fanart)
return
def getChannelItems(self, name, url, fanart):
soup = self.getSoup(url)
channel_list = soup.find('channel', attrs={'name': name})
items = channel_list('item')
try:
fanArt = channel_list('fanart')[0].string
if fanArt == None:
raise
except:
fanArt = fanart
for channel in channel_list('subchannel'):
name = channel('name')[0].string
try:
thumbnail = channel('thumbnail')[0].string
if thumbnail == None:
raise
except:
thumbnail = ''
try:
if not channel('fanart'):
if __settings__.getSetting('use_thumb') == 'true':
fanArt = thumbnail
else:
fanArt = channel('fanart')[0].string
if fanArt == None:
raise
except:
pass
try:
desc = channel('info')[0].string
if desc == None:
raise
except:
desc = ''
try:
genre = channel('genre')[0].string
if genre == None:
raise
except:
genre = ''
try:
date = channel('date')[0].string
if date == None:
raise
except:
date = ''
try:
self.addDir(name.encode('utf-8', 'ignore'), url, 3, thumbnail, fanArt, desc, genre, date)
except:
print 'nothing to say........'
print 'nothing to say........'
self.getItems(items, fanArt)
return
def getSubChannelItems(self, name, url, fanart):
print 'nothing to say........'
soup = self.getSoup(url)
channel_list = soup.find('subchannel', attrs={'name': name})
items = channel_list('subitem')
self.getItems(items, fanart)
def getItems(self, items, fanart):
print 'Inside getItems'
for item in items:
try:
name = item('title')[0].string
except:
print '-----Name Error----'
name = ''
try:
if self.__settings__.getSetting('mirror_link') == 'true':
try:
url = item('link')[1].string
except:
url = item('link')[0].string
if self.__settings__.getSetting('mirror_link_low') == 'true':
try:
url = item('link')[2].string
except:
try:
url = item('link')[1].string
except:
url = item('link')[0].string
else:
url = item('link')[0].string
except:
print '---- URL Error Passing ----' + name
try:
thumbnail = item('thumbnail')[0].string
if thumbnail == None:
raise
except:
thumbnail = ''
try:
if not item('fanart'):
if self.__settings__.getSetting('use_thumb') == 'true':
fanArt = thumbnail
else:
fanArt = fanart
else:
fanArt = item('fanart')[0].string
if fanArt == None:
raise
except:
fanArt = fanart
try:
self.addLink(url, name.encode('utf-8', 'ignore'), thumbnail, '', '', '', '', True)
except:
print 'nothing to say........'
return
def get_params(self):
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
def addDir(self, name, url, mode, iconimage, fanart, description, genre, date, showcontext = True):
u = sys.argv[0] + '?url=' + urllib.quote_plus(url) + '&mode=' + str(mode) + '&name=' + urllib.quote_plus(name) + '&fanart=' + urllib.quote_plus(fanart)
ok = True
liz = xbmcgui.ListItem(name, iconImage='DefaultFolder.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title': name,
'Plot': description,
'Genre': genre,
'Date': date})
liz.setProperty('Fanart_Image', fanart)
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True)
return ok
def addLink(self, url, name, iconimage, fanart, description, genre, date, showcontext = True):
if '127.0.0.1' in url:
mode = self.PLUGIN_MODE_VOD
self.addDir(name, url, mode, iconimage, fanart, description, genre, date, showcontext)
return
if '127.0.0.2' in url:
mode = self.PLUGIN_MODE_VOD2
self.addDir(name, url, mode, iconimage, fanart, description, genre, date, showcontext)
return
ok = True
guid = ''
environment = os.environ.get('OS', 'xbox')
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title': name,
'Plot': description,
'Genre': genre,
'Date': date})
liz.setProperty('Fanart_Image', fanart)
if '127.0.0.1' in url or 'securitytype=2' in url:
mode = self.PLUGIN_MODE_PLAY_VUXMLSTREAM
elif 'vuxml.php' in url:
mode = self.PLUGIN_MODE_PLAY_VUXMLSTREAM
elif 'youtube.com' in url:
mode = self.PLUGIN_MODE_PLAY_YT_VIDEO
guid = url.replace('http://www.youtube.com/watch?v=', '')
elif 'dag1.asx' in url:
mode = self.PLUGIN_MODE_PLAY_DAGSTREAM
elif 'smil' in url and '.m3u8' in url:
mode = self.PLUGIN_MODE_PLAY_YUPP
else:
mode = self.PLUGIN_MODE_PLAY_STREAM
url = sys.argv[0] + '?mode=%d&name=%s&url=%s&thumb=%s&guid=%s' % (mode,
urllib.quote_plus(name),
urllib.quote_plus(url),
urllib.quote_plus(iconimage),
guid)
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=liz)
return ok
def get_match(self, data, regex):
match = ''
m = re.search(regex, data)
if m != None:
match = m.group(1)
else:
match = ''
return match
def cache_page(self, url, isMobile = False, ref = ''):
req = urllib2.Request(url)
if isMobile:
req.add_header('User-Agent', 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7')
req.add_header('User-Agent', 'Verismo-BlackUI_(2.4.7.5.8.0.34)')
else:
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
if ref != '':
req.add_header('Referer', ref)
response = urllib2.urlopen(req)
data = response.read()
response.close()
return data
def cache(self, url):
req = urllib2.Request(url)
req.add_header('Pragma', 'no-cache')
req.add_header('User-Agent', '(XBMC) IPTVExpress/' + self.plugin_ver)
try:
response = urllib2.build_opener().open(req)
data = response.read()
response.close()
except:
self.message('\nServer is not reachable. Check your internet or try later.', 'ERROR')
data = ''
return data
def resolve_einthusan(self, url, guid):
xbmc.log('Starting resolve_einthusan with url: ' + str(url))
data = cache_page(url)
location = get_match(data, "'file': *'([^']+movie_high[^']+)'")
if not location:
location = 'CONTENTREMOVED'
return location
def playVuxmlStream(self, name, url, thumb):
location = ''
if '127.0.0.1' in url:
data = url
elif 'securitytype=2' in url:
import requests
r = requests.get(url, allow_redirects=False)
data = r.headers.get('Location')
else:
data = self.cache_page(url, True)
if '127.0.0.1' in data:
location = self.get_match(data, '&ver_t=([^&]+)&') + ' live=true timeout=15 playpath=' + self.get_match(data, '\\?y=([a-zA-Z0-9-_\\.@]+)')
if self.get_match(data, 'token=([^&]+)&') != '':
location = location + '?token=' + self.get_match(data, 'token=([^&]+)&')
elif self.get_match(data, 'wmsAuthSign%3D([^%&]+)') != '':
location = self.get_match(data, '&ver_t=([^&]+)&') + '?wmsAuthSign=' + self.get_match(data, 'wmsAuthSign%3D([^%&]+)') + '==/mp4:' + self.get_match(data, '\\?y=([^&]+)&')
else:
location = self.get_match(data, 'HREF="([^"]+)"')
if 'dag1.asx' in location:
self.playDagStream(name, location, thumb)
if location != '':
location = self.addOptionalStreamArgs(location)
else:
print 'passing to dagstream'
if 'devinlivefs.fplive.net' not in location:
location = location.replace('devinlive', 'flive')
self.play_stream(location, name)
def addOptionalStreamArgs(self, url):
if 'timeout=' not in url and (url.startswith('rtmpe://') or url.startswith('rtmp://')):
url = url + ' timeout=30'
return url
def playDagStream(self, name, origurl, thumb):
location = ''
origurl = origurl.replace('dag.total-stream.net', 'dag-sj2.totalstream.net')
data = self.cache_page(origurl, True)
if '127.0.0.1' in data:
print 'nothing to say........'
self.playVuxmlStream(name, origurl, thumb)
elif self.get_match(data, 'wmsAuthSign%3D([^%&]+)') != '':
location = self.get_match(data, '&ver_t=([^&]+)&') + '?wmsAuthSign=' + self.get_match(data, 'wmsAuthSign%3D([^%&]+)') + '==/mp4:' + self.get_match(data, '\\?y=([^&]+)&')
else:
location = self.get_match(data, 'href="([^"]+)"[^"]+$')
location = location.replace(' ', '%20')
if location != '':
location = self.addOptionalStreamArgs(location)
self.play_stream(location, name)
def playEboundStream(self, name, url, thumb, ref):
print 'nothing to say........'
data = self.cache_page(url, False, ref)
if self.get_match(data, 'href="(http[^"]+m3u8[^"]+)"') != '':
location = self.get_match(data, 'href="(http[^"]+m3u8[^"]+)"')
self.play_stream(location, name)
elif self.get_match(data, "(rtmp[^']+)") != '':
playpath = self.get_match(url, '&stream=([^&]+)&')
location = self.get_match(data, "(rtmp[^']+)") + ' playpath=' + playpath
self.play_stream(location, name)
def play_yupp(self, url, name):
data = self.cache_page(url, True)
if self.get_match(data, '(http.+)') != '':
location = self.get_match(data, '(http.+)')
self.play_stream(location, name)
def play_iptvexpress(self, url, name):
data = self.cache(url)
if self.get_match(data, '(.+)') != '':
location = self.get_match(data, '(http.+)|(rtmp.+)')
self.play_stream(location, name)
def play_youtube_video(self, video_id, name):
print 'nothing to say........'
url = 'plugin://plugin.video.youtube/?action=play_video&videoid=%s' % video_id
listitem = xbmcgui.ListItem(label=str(name), iconImage='DefaultVideo.png', thumbnailImage=xbmc.getInfoImage('ListItem.Thumb'), path=url)
infolabels = {'Title': name,
'Path': url}
listitem.setInfo(type='Video', infoLabels=infolabels)
xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(str(url), listitem)
def play_urlresolved_stream(self, url, name):
location = urlresolver.resolve(url)
if location is not None and location != False and isinstance(location, basestring):
self.play_stream(location, name)
else:
print 'nothing to say........'
return
def play_billion_uploads(self, url, name):
data = self.cache_page(url)
if self.get_match(data, 'name="op" value="([^"]+)"') != '':
print 'nothing to say........'
op = self.get_match(data, 'name="op" value="([^"]+)"')
id = self.get_match(data, 'name="id" value="([^"]+)"')
rand = self.get_match(data, 'name="rand" value="([^"]+)"')
method_free = self.get_match(data, 'name="method_free" value="([^"]+)"')
down_direct = self.get_match(data, 'name="down_direct" value="([^"]+)"')
values = {'op': op,
'id': id,
'rand': rand,
'method_free': method_free,
'down_direct': down_direct,
'referer': url}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
print 'nothing to say........'
xbmc.sleep(3000)
response = urllib2.urlopen(req)
data = response.read()
response.close()
if self.get_match(data, 'product_download_url=([^"]+)"') != '':
location = self.get_match(data, 'product_download_url=([^"]+)"')
self.play_stream(location, name)
else:
print 'nothing to say........'
else:
print 'nothing to say........'
def macid(self):
try:
mac = open('/sys/class/net/eth0/address').read()
except:
try:
mac = open('/sys/class/net/wlan0/address').read()
except:
try:
from uuid import getnode as get_mac
mac = hex(get_mac())[2:-1]
count = 0
if len(mac) < 12:
while 12 - len(mac) >= count:
mac = '0' + mac
count = count + 1
except:
return 'MACERROR'
mac = mac.replace(':', '')
mac = mac[0:12]
mac = mac.upper()
return mac
def serid(self):
ser = ''
status = 0
macad = self.macid()
if self.os == 'OSX':
return self.macSerial()
try:
f = open('/proc/cpuinfo', 'r')
for line in f:
if line[0:6] == 'Serial':
ser = line[10:26]
f.close()
except:
ser = '00000000000ERROR'
if '00000000000' in ser or ser == '':
try:
flag = 0
file_path = os.path.dirname(__file__)
if file_path != '':
os.chdir(file_path)
filepath = xbmc.translatePath(os.path.join(self.profile, 'data'))
filepath2 = xbmc.translatePath(os.path.join(self.profile, 'id'))
if os.path.exists(filepath) == False:
flag = 1
self.Download(self.base_url + '/secured/serial/generate.php?env=' + self.os + '&id2=' + macad, filepath)
with open(filepath, 'r') as f:
ser = f.readline()
if len(ser) != 16:
self.message('End up with error 1500.', 'ERROR')
shutil.rmtree(self.profile)
exit()
return
if flag:
self.message(ser)
except:
self.message('This device is not supported', 'ERROR')
return 'ERROR'
return ser
def play_stream(self, url, name, ref = ''):
player = xbmc.Player()
if player.isPlaying():
player.stop()
if ref is not None and ref != '':
url = url + '|referer=' + ref
listitem = xbmcgui.ListItem(label=str(name), iconImage='DefaultVideo.png', thumbnailImage=xbmc.getInfoImage('ListItem.Thumb'), path=url)
listitem.setInfo(type='video', infoLabels={'Title': name,
'Path': url})
xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(str(url), listitem)
return
def get_category(self, url, name, iconimage, fanart, origurl, shareurl, thumb, guid, mode, page, index, ref):
print 'nothing to say........'
data = self.cache(self.base_url + '/secured/status.php?' + self.security_url)
if data == '':
exit()
if 'Account is active' not in data:
self.message(data)
exit()
elif mode == None:
print 'nothing to say........'
self.getSources()
elif mode == 1:
print 'nothing to say........'
self.getData(url, fanart)
elif mode == 2:
print 'nothing to say........'
self.getChannelItems(name, url, fanart)
elif mode == 3:
print 'nothing to say........'
self.getSubChannelItems(name, url, fanart)
elif mode == 4:
print 'nothing to say........'
self.getFavorites()
elif mode == 5:
print 'nothing to say........'
try:
name = name.split('\\ ')[1]
except:
pass
try:
name = name.split(' - ')[0]
except:
pass
self.addFavorite(name, url, iconimage, fanart)
elif mode == 6:
print 'nothing to say........'
try:
name = name.split('\\ ')[1]
except:
pass
try:
name = name.split(' - ')[0]
except:
pass
self.rmFavorite(name)
elif mode == 7:
print 'nothing to say........'
self.addSource(url)
elif mode == 8:
print 'nothing to say........'
self.rmSource(name)
elif mode == 11:
print 'nothing to say........'
self.addSource(url)
elif mode == 12:
print 'nothing to say........'
elif mode == self.PLUGIN_MODE_PLAY_YT_VIDEO:
self.play_youtube_video(guid, name)
elif mode == self.PLUGIN_MODE_QUERY_DB:
self.build_search_directory('querydb')
elif mode == self.PLUGIN_MODE_QUERY_YT:
self.build_search_directory('queryyt')
elif mode == self.PLUGIN_MODE_QUERY_DM:
self.build_search_directory('querydm')
elif mode == self.PLUGIN_MODE_BUILD_YT_USER:
self.build_user_directory('id')
elif mode == self.PLUGIN_MODE_BUILD_DM_USER:
self.build_user_directory('dmid')
elif mode == self.PLUGIN_MODE_BUILD_YT_FAV:
self.build_ytuser_favs_directory()
elif mode == self.PLUGIN_MODE_PLAY_PLAYLIST:
self.play_playlist(url, index)
elif mode == self.PLUGIN_MODE_PLAY_SLIDESHOW:
self.play_picture_slideshow(url, name)
elif mode == self.PLUGIN_MODE_PLAY_STREAM:
self.play_stream(url, name)
elif mode == self.PLUGIN_MODE_OPEN_SETTINGS:
self.open_settings()
elif mode == self.PLUGIN_MODE_PLAY_4SHARED:
self.play_fourshared(url, name)
elif mode == self.PLUGIN_MODE_DOWNLOAD:
self.download(url, name, guid, True)
elif mode == self.PLUGIN_MODE_DOWNLOAD_ALL:
self.download_all(origurl, name)
elif mode == self.PLUGIN_MODE_QUERY:
self.custom_search_directory(url, name)
elif mode == self.PLUGIN_MODE_OPEN_DOWNLOADS:
self.open_download_dir()
elif mode == self.PLUGIN_MODE_PLAY_DESISTREAM:
self.play_desistreamtv(name, url, thumb)
elif mode == self.PLUGIN_MODE_PLAY_VUXMLSTREAM:
self.playVuxmlStream(name, url, thumb)
elif mode == self.PLUGIN_MODE_PLAY_DAGSTREAM:
self.playDagStream(name, url, thumb)
elif mode == self.PLUGIN_MODE_OPEN_PLUGIN:
self.open_plugin(url)
elif mode == self.PLUGIN_MODE_PLAY_EBOUND:
self.playEboundStream(name, url, thumb, ref)
elif mode == self.PLUGIN_MODE_PLAY_URLRESOLVER:
self.play_urlresolved_stream(url, name)
elif mode == self.PLUGIN_MODE_PLAY_YUPP:
self.play_yupp(url, name)
elif mode == self.PLUGIN_MODE_PLAY_IPTVEXPRESS:
self.play_iptvexpress(url, name)
elif mode == self.PLUGIN_MODE_PLAY_BILLIONUPLOADS:
self.play_billion_uploads(url, name)
elif mode == self.PLUGIN_MODE_PLAY_NOVAMOV:
self.play_novamov(url, guid)
elif mode == self.PLUGIN_MODE_VOD or mode == self.PLUGIN_MODE_VOD2:
self.getVOD(url)
if mode == self.PLUGIN_MODE_VOD:
xbmc.executebuiltin('Container.SetViewMode(502)')
else:
xbmc.executebuiltin('Container.SetViewMode(500)')
return
import utils, httplib2, socks, httplib, logging, time
import urllib, re
import xbmc, xbmcgui
import time
import urllib2
import shutil
import urlparse
import os
import os.path
import hashlib
import xbmcplugin
import xbmcaddon
import xbmcvfs
import string, sys, traceback, unicodedata, cookielib
import xml.dom.minidom, base64
from BeautifulSoup import BeautifulStoneSoup, BeautifulSoup, BeautifulSOAP
try:
import json
except:
import simplejson as json
class iptvex:
PLUGIN_MODE_PLAY_YT_VIDEO = 20
PLUGIN_MODE_QUERY_DB = 30
PLUGIN_MODE_QUERY_YT = 40
PLUGIN_MODE_BUILD_YT_USER = 50
PLUGIN_MODE_BUILD_YT_FAV = 60
PLUGIN_MODE_PLAY_PLAYLIST = 80
PLUGIN_MODE_PLAY_SLIDESHOW = 90
PLUGIN_MODE_OPEN_SETTINGS = 100
PLUGIN_MODE_PLAY_STREAM = 110
PLUGIN_MODE_PLAY_4SHARED = 120
PLUGIN_MODE_QUERY_DM = 130
PLUGIN_MODE_BUILD_DM_USER = 140
PLUGIN_MODE_GET_USERINFO = 150
PLUGIN_MODE_DOWNLOAD = 160
PLUGIN_MODE_QUERY = 170
PLUGIN_MODE_OPEN_DOWNLOADS = 180
PLUGIN_MODE_DOWNLOAD_ALL = 190
PLUGIN_MODE_PLAY_DESISTREAM = 200
PLUGIN_MODE_SHARE_EMAIL = 210
PLUGIN_MODE_PLAY_VUXMLSTREAM = 220
PLUGIN_MODE_PLAY_DAGSTREAM = 230
PLUGIN_MODE_OPEN_PLUGIN = 240
PLUGIN_MODE_PLAY_EBOUND = 250
PLUGIN_MODE_PLAY_URLRESOLVER = 260
PLUGIN_MODE_PLAY_YUPP = 270
PLUGIN_MODE_PLAY_BILLIONUPLOADS = 280
PLUGIN_MODE_PLAY_NOVAMOV = 290
PLUGIN_MODE_PLAY_IPTVEXPRESS = 300
PLUGIN_MODE_VOD = 500
PLUGIN_MODE_VOD2 = 510
def __init__(self):
self.os = str(self.get_os())
if self.os != 'OSX':
from sys import exit
self.message('Wrong device', 'ERROR')
exit()
self.base_url = 'https://iptvexpress.com'
self.plugin_ver = '3.0.0'
self.plugin_name = 'plugin.video.IPTV.Express'
self.addon = xbmcaddon.Addon(self.plugin_name)
self.profile = xbmc.translatePath(self.addon.getAddonInfo('profile'))
self.__settings__ = xbmcaddon.Addon(id=self.plugin_name)
self.home = self.__settings__.getAddonInfo('path')
self.favorites = xbmc.translatePath(os.path.join(self.profile, 'favorites'))
self.REV = xbmc.translatePath(os.path.join(self.profile, 'list_revision'))
self.icon = xbmc.translatePath(os.path.join(self.home, 'icon.png'))
self.fanart = xbmc.translatePath(os.path.join(self.home, 'fanart.jpg'))
self.source_file = xbmc.translatePath(os.path.join(self.profile, 'source_file'))
if os.path.exists(self.favorites) == True:
self.FAV = open(self.favorites).read()
if os.path.exists(self.source_file) == True:
self.SOURCES = open(self.source_file).read()
self.__scriptname__ = 'IPTV.Express'
self.__scriptid__ = self.plugin_name
self.__addoninfo__ = utils.get_addoninfo(self.__scriptid__)
self.__addon__ = self.__addoninfo__['addon']
self.__settings__ = xbmcaddon.Addon(id=self.__scriptid__)
self.DIR_USERDATA = xbmc.translatePath(self.__addoninfo__['profile'])
self.SUBTITLES_DIR = os.path.join(self.DIR_USERDATA, 'Subtitles')
self.IMAGE_DIR = os.path.join(self.DIR_USERDATA, 'Images')
if not os.path.isdir(self.DIR_USERDATA):
os.makedirs(self.DIR_USERDATA)
if not os.path.isdir(self.SUBTITLES_DIR):
os.makedirs(self.SUBTITLES_DIR)
if not os.path.isdir(self.IMAGE_DIR):
os.makedirs(self.IMAGE_DIR)
self.security_url = 'id=' + self.encid(self.serid()) + '&id2=' + self.macid() + '&env=' + self.os
def getSources(self):
file_path = os.path.dirname(__file__)
if file_path != '':
os.chdir(file_path)
if os.path.exists(self.favorites) == True:
self.addDir('Favorites', 'url', 4, xbmc.translatePath(os.path.join(self.home, 'resources', 'favorites.png')), self.fanart, '', '', '', False)
cache_url = self.base_url + '/secured/fetchdata.php?' + self.security_url + '&source=true'
sources = json.loads(self.cache(cache_url))
if len(sources) > 0:
for i in sources:
self.addDir(i[0], i[1], 1, i[2], self.fanart, '', '', '')
else:
if os.path.exists(self.favorites):
os.remove(self.favorites)
self.message(self.cache(self.base_url + '/secured/status.php?' + self.security_url), self.serid())
def get_os(self):
try:
xbmc_os = os.environ.get('OS')
except:
xbmc_os = 'unknown'
return xbmc_os.replace(' ', '')
def getVOD(self, url = None):
if '127.0.0.1' in url:
url = url.replace('127.0.0.1', 'iptvexpress.com')
elif '127.0.0.2' in url:
url = url.replace('127.0.0.2', 'iptvexpress.com')
sources = json.loads(self.cache(url + '&' + self.security_url))
for i in sources:
self.addDir(i[0], i[1], 1, i[2], self.fanart, '', '', '')
def encid(self, no):
enc = hashlib.md5(no).hexdigest()
return enc
def Download(self, url, dest):
output = open(dest, 'wb')
output.write(self.cache(url))
output.close()
def message(self, msg, title = 'IPTV Express - Activation Code'):
dialog = xbmcgui.Dialog()
dialog.ok(title, msg)
def macSerial(self):
from ctypes import *
from ctypes import util
iokit = cdll.LoadLibrary(util.find_library('IOKit'))
cf = cdll.LoadLibrary(util.find_library('CoreFoundation'))
cf.CFStringCreateWithCString.argtypes = [c_void_p, c_char_p, c_int32]
cf.CFStringCreateWithCString.restype = c_void_p
cf.CFStringGetCStringPtr.argtypes = [c_void_p, c_uint32]
cf.CFStringGetCStringPtr.restype = c_char_p
kCFAllocatorDefault = c_void_p.in_dll(cf, 'kCFAllocatorDefault')
kCFStringEncodingMacRoman = 0
kIOMasterPortDefault = c_void_p.in_dll(iokit, 'kIOMasterPortDefault')
kIOPlatformSerialNumberKey = 'IOPlatformSerialNumber'.encode('mac_roman')
iokit.IOServiceMatching.restype = c_void_p
iokit.IOServiceGetMatchingService.argtypes = [c_void_p, c_void_p]
iokit.IOServiceGetMatchingService.restype = c_void_p
iokit.IORegistryEntryCreateCFProperty.argtypes = [c_void_p,
c_void_p,
c_void_p,
c_uint32]
iokit.IORegistryEntryCreateCFProperty.restype = c_void_p
iokit.IOObjectRelease.argtypes = [c_void_p]
SERIAL = None
if SERIAL is None:
platformExpert = iokit.IOServiceGetMatchingService(kIOMasterPortDefault, iokit.IOServiceMatching('IOPlatformExpertDevice'))
if platformExpert:
key = cf.CFStringCreateWithCString(kCFAllocatorDefault, kIOPlatformSerialNumberKey, kCFStringEncodingMacRoman)
serialNumberAsCFString = iokit.IORegistryEntryCreateCFProperty(platformExpert, key, kCFAllocatorDefault, 0)
if serialNumberAsCFString:
SERIAL = cf.CFStringGetCStringPtr(serialNumberAsCFString, 0)
iokit.IOObjectRelease(platformExpert)
return SERIAL
def getSoup(self, url):
if url.startswith('http://') or url.startswith('https://'):
try:
if 'php?' in url or 'xml?' in url:
url += '&' + self.security_url
else:
url += '?' + self.security_url
data = self.cache(url)
except urllib2.URLError as e:
if hasattr(e, 'code'):
xbmc.executebuiltin('XBMC.Notification(IPTV Express,We failed with error code - ' + str(e.code) + ',10000,' + self.icon + ')')
elif hasattr(e, 'reason'):
xbmc.executebuiltin('XBMC.Notification(IPTV Express,We failed to reach a server. - ' + str(e.reason) + ',10000,' + self.icon + ')')
elif xbmcvfs.exists(url):
if url.startswith('smb://'):
copy = xbmcvfs.copy(url, xbmc.translatePath(os.path.join(self.profile, 'temp', 'sorce_temp.txt')))
if copy:
data = open(xbmc.translatePath(os.path.join(self.profile, 'temp', 'sorce_temp.txt')), 'r').read()
xbmcvfs.delete(xbmc.translatePath(os.path.join(self.profile, 'temp', 'sorce_temp.txt')))
else:
data = open(url, 'r').read()
else:
return
soup = BeautifulSOAP(data, convertEntities=BeautifulStoneSoup.XML_ENTITIES)
return soup
def getData(self, url, fanart):
soup = self.getSoup(url)
if len(soup('channels')):
channels = soup('channel')
for channel in channels:
name = channel('name')[0].string
thumbnail = channel('thumbnail')[0].string
if thumbnail == None:
thumbnail = ''
try:
if not channel('fanart'):
if self.__settings__.getSetting('use_thumb') == 'true':
fanArt = thumbnail
else:
fanArt = fanart
else:
fanArt = channel('fanart')[0].string
if fanArt == None:
raise
except:
fanArt = fanart
try:
desc = channel('info')[0].string
if desc == None:
raise
except:
desc = ''
try:
genre = channel('genre')[0].string
if genre == None:
raise
except:
genre = ''
try:
date = channel('date')[0].string
if date == None:
raise
except:
date = ''
try:
self.addDir(name.encode('utf-8', 'ignore'), url, 2, thumbnail, fanArt, desc, genre, date)
except:
print 'nothing to say........'
else:
self.getItems(soup('item'), fanart)
return
def getChannelItems(self, name, url, fanart):
soup = self.getSoup(url)
channel_list = soup.find('channel', attrs={'name': name})
items = channel_list('item')
try:
fanArt = channel_list('fanart')[0].string
if fanArt == None:
raise
except:
fanArt = fanart
for channel in channel_list('subchannel'):
name = channel('name')[0].string
try:
thumbnail = channel('thumbnail')[0].string
if thumbnail == None:
raise
except:
thumbnail = ''
try:
if not channel('fanart'):
if __settings__.getSetting('use_thumb') == 'true':
fanArt = thumbnail
else:
fanArt = channel('fanart')[0].string
if fanArt == None:
raise
except:
pass
try:
desc = channel('info')[0].string
if desc == None:
raise
except:
desc = ''
try:
genre = channel('genre')[0].string
if genre == None:
raise
except:
genre = ''
try:
date = channel('date')[0].string
if date == None:
raise
except:
date = ''
try:
self.addDir(name.encode('utf-8', 'ignore'), url, 3, thumbnail, fanArt, desc, genre, date)
except:
print 'nothing to say........'
print 'nothing to say........'
self.getItems(items, fanArt)
return
def getSubChannelItems(self, name, url, fanart):
print 'nothing to say........'
soup = self.getSoup(url)
channel_list = soup.find('subchannel', attrs={'name': name})
items = channel_list('subitem')
self.getItems(items, fanart)
def getItems(self, items, fanart):
print 'Inside getItems'
for item in items:
try:
name = item('title')[0].string
except:
print '-----Name Error----'
name = ''
try:
if self.__settings__.getSetting('mirror_link') == 'true':
try:
url = item('link')[1].string
except:
url = item('link')[0].string
if self.__settings__.getSetting('mirror_link_low') == 'true':
try:
url = item('link')[2].string
except:
try:
url = item('link')[1].string
except:
url = item('link')[0].string
else:
url = item('link')[0].string
except:
print '---- URL Error Passing ----' + name
try:
thumbnail = item('thumbnail')[0].string
if thumbnail == None:
raise
except:
thumbnail = ''
try:
if not item('fanart'):
if self.__settings__.getSetting('use_thumb') == 'true':
fanArt = thumbnail
else:
fanArt = fanart
else:
fanArt = item('fanart')[0].string
if fanArt == None:
raise
except:
fanArt = fanart
try:
self.addLink(url, name.encode('utf-8', 'ignore'), thumbnail, '', '', '', '', True)
except:
print 'nothing to say........'
return
def get_params(self):
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
def addDir(self, name, url, mode, iconimage, fanart, description, genre, date, showcontext = True):
u = sys.argv[0] + '?url=' + urllib.quote_plus(url) + '&mode=' + str(mode) + '&name=' + urllib.quote_plus(name) + '&fanart=' + urllib.quote_plus(fanart)
ok = True
liz = xbmcgui.ListItem(name, iconImage='DefaultFolder.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title': name,
'Plot': description,
'Genre': genre,
'Date': date})
liz.setProperty('Fanart_Image', fanart)
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True)
return ok
def addLink(self, url, name, iconimage, fanart, description, genre, date, showcontext = True):
if '127.0.0.1' in url:
mode = self.PLUGIN_MODE_VOD
self.addDir(name, url, mode, iconimage, fanart, description, genre, date, showcontext)
return
if '127.0.0.2' in url:
mode = self.PLUGIN_MODE_VOD2
self.addDir(name, url, mode, iconimage, fanart, description, genre, date, showcontext)
return
ok = True
guid = ''
environment = os.environ.get('OS', 'xbox')
liz = xbmcgui.ListItem(name, iconImage='DefaultVideo.png', thumbnailImage=iconimage)
liz.setInfo(type='Video', infoLabels={'Title': name,
'Plot': description,
'Genre': genre,
'Date': date})
liz.setProperty('Fanart_Image', fanart)
if '127.0.0.1' in url or 'securitytype=2' in url:
mode = self.PLUGIN_MODE_PLAY_VUXMLSTREAM
elif 'vuxml.php' in url:
mode = self.PLUGIN_MODE_PLAY_VUXMLSTREAM
elif 'youtube.com' in url:
mode = self.PLUGIN_MODE_PLAY_YT_VIDEO
guid = url.replace('http://www.youtube.com/watch?v=', '')
elif 'dag1.asx' in url:
mode = self.PLUGIN_MODE_PLAY_DAGSTREAM
elif 'smil' in url and '.m3u8' in url:
mode = self.PLUGIN_MODE_PLAY_YUPP
else:
mode = self.PLUGIN_MODE_PLAY_STREAM
url = sys.argv[0] + '?mode=%d&name=%s&url=%s&thumb=%s&guid=%s' % (mode,
urllib.quote_plus(name),
urllib.quote_plus(url),
urllib.quote_plus(iconimage),
guid)
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=liz)
return ok
def get_match(self, data, regex):
match = ''
m = re.search(regex, data)
if m != None:
match = m.group(1)
else:
match = ''
return match
def cache_page(self, url, isMobile = False, ref = ''):
req = urllib2.Request(url)
if isMobile:
req.add_header('User-Agent', 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7')
req.add_header('User-Agent', 'Verismo-BlackUI_(2.4.7.5.8.0.34)')
else:
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
if ref != '':
req.add_header('Referer', ref)
response = urllib2.urlopen(req)
data = response.read()
response.close()
return data
def cache(self, url):
req = urllib2.Request(url)
req.add_header('Pragma', 'no-cache')
req.add_header('User-Agent', '(XBMC) IPTVExpress/' + self.plugin_ver)
try:
response = urllib2.build_opener().open(req)
data = response.read()
response.close()
except:
self.message('\nServer is not reachable. Check your internet or try later.', 'ERROR')
data = ''
return data
def resolve_einthusan(self, url, guid):
xbmc.log('Starting resolve_einthusan with url: ' + str(url))
data = cache_page(url)
location = get_match(data, "'file': *'([^']+movie_high[^']+)'")
if not location:
location = 'CONTENTREMOVED'
return location
def playVuxmlStream(self, name, url, thumb):
location = ''
if '127.0.0.1' in url:
data = url
elif 'securitytype=2' in url:
import requests
r = requests.get(url, allow_redirects=False)
data = r.headers.get('Location')
else:
data = self.cache_page(url, True)
if '127.0.0.1' in data:
location = self.get_match(data, '&ver_t=([^&]+)&') + ' live=true timeout=15 playpath=' + self.get_match(data, '\\?y=([a-zA-Z0-9-_\\.@]+)')
if self.get_match(data, 'token=([^&]+)&') != '':
location = location + '?token=' + self.get_match(data, 'token=([^&]+)&')
elif self.get_match(data, 'wmsAuthSign%3D([^%&]+)') != '':
location = self.get_match(data, '&ver_t=([^&]+)&') + '?wmsAuthSign=' + self.get_match(data, 'wmsAuthSign%3D([^%&]+)') + '==/mp4:' + self.get_match(data, '\\?y=([^&]+)&')
else:
location = self.get_match(data, 'HREF="([^"]+)"')
if 'dag1.asx' in location:
self.playDagStream(name, location, thumb)
if location != '':
location = self.addOptionalStreamArgs(location)
else:
print 'passing to dagstream'
if 'devinlivefs.fplive.net' not in location:
location = location.replace('devinlive', 'flive')
self.play_stream(location, name)
def addOptionalStreamArgs(self, url):
if 'timeout=' not in url and (url.startswith('rtmpe://') or url.startswith('rtmp://')):
url = url + ' timeout=30'
return url
def playDagStream(self, name, origurl, thumb):
location = ''
origurl = origurl.replace('dag.total-stream.net', 'dag-sj2.totalstream.net')
data = self.cache_page(origurl, True)
if '127.0.0.1' in data:
print 'nothing to say........'
self.playVuxmlStream(name, origurl, thumb)
elif self.get_match(data, 'wmsAuthSign%3D([^%&]+)') != '':
location = self.get_match(data, '&ver_t=([^&]+)&') + '?wmsAuthSign=' + self.get_match(data, 'wmsAuthSign%3D([^%&]+)') + '==/mp4:' + self.get_match(data, '\\?y=([^&]+)&')
else:
location = self.get_match(data, 'href="([^"]+)"[^"]+$')
location = location.replace(' ', '%20')
if location != '':
location = self.addOptionalStreamArgs(location)
self.play_stream(location, name)
def playEboundStream(self, name, url, thumb, ref):
print 'nothing to say........'
data = self.cache_page(url, False, ref)
if self.get_match(data, 'href="(http[^"]+m3u8[^"]+)"') != '':
location = self.get_match(data, 'href="(http[^"]+m3u8[^"]+)"')
self.play_stream(location, name)
elif self.get_match(data, "(rtmp[^']+)") != '':
playpath = self.get_match(url, '&stream=([^&]+)&')
location = self.get_match(data, "(rtmp[^']+)") + ' playpath=' + playpath
self.play_stream(location, name)
def play_yupp(self, url, name):
data = self.cache_page(url, True)
if self.get_match(data, '(http.+)') != '':
location = self.get_match(data, '(http.+)')
self.play_stream(location, name)
def play_iptvexpress(self, url, name):
data = self.cache(url)
if self.get_match(data, '(.+)') != '':
location = self.get_match(data, '(http.+)|(rtmp.+)')
self.play_stream(location, name)
def play_youtube_video(self, video_id, name):
print 'nothing to say........'
url = 'plugin://plugin.video.youtube/?action=play_video&videoid=%s' % video_id
listitem = xbmcgui.ListItem(label=str(name), iconImage='DefaultVideo.png', thumbnailImage=xbmc.getInfoImage('ListItem.Thumb'), path=url)
infolabels = {'Title': name,
'Path': url}
listitem.setInfo(type='Video', infoLabels=infolabels)
xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(str(url), listitem)
def play_urlresolved_stream(self, url, name):
location = urlresolver.resolve(url)
if location is not None and location != False and isinstance(location, basestring):
self.play_stream(location, name)
else:
print 'nothing to say........'
return
def play_billion_uploads(self, url, name):
data = self.cache_page(url)
if self.get_match(data, 'name="op" value="([^"]+)"') != '':
print 'nothing to say........'
op = self.get_match(data, 'name="op" value="([^"]+)"')
id = self.get_match(data, 'name="id" value="([^"]+)"')
rand = self.get_match(data, 'name="rand" value="([^"]+)"')
method_free = self.get_match(data, 'name="method_free" value="([^"]+)"')
down_direct = self.get_match(data, 'name="down_direct" value="([^"]+)"')
values = {'op': op,
'id': id,
'rand': rand,
'method_free': method_free,
'down_direct': down_direct,
'referer': url}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
print 'nothing to say........'
xbmc.sleep(3000)
response = urllib2.urlopen(req)
data = response.read()
response.close()
if self.get_match(data, 'product_download_url=([^"]+)"') != '':
location = self.get_match(data, 'product_download_url=([^"]+)"')
self.play_stream(location, name)
else:
print 'nothing to say........'
else:
print 'nothing to say........'
def macid(self):
try:
mac = open('/sys/class/net/eth0/address').read()
except:
try:
mac = open('/sys/class/net/wlan0/address').read()
except:
try:
from uuid import getnode as get_mac
mac = hex(get_mac())[2:-1]
count = 0
if len(mac) < 12:
while 12 - len(mac) >= count:
mac = '0' + mac
count = count + 1
except:
return 'MACERROR'
mac = mac.replace(':', '')
mac = mac[0:12]
mac = mac.upper()
return mac
def serid(self):
ser = ''
status = 0
macad = self.macid()
if self.os == 'OSX':
return self.macSerial()
try:
f = open('/proc/cpuinfo', 'r')
for line in f:
if line[0:6] == 'Serial':
ser = line[10:26]
f.close()
except:
ser = '00000000000ERROR'
if '00000000000' in ser or ser == '':
try:
flag = 0
file_path = os.path.dirname(__file__)
if file_path != '':
os.chdir(file_path)
filepath = xbmc.translatePath(os.path.join(self.profile, 'data'))
filepath2 = xbmc.translatePath(os.path.join(self.profile, 'id'))
if os.path.exists(filepath) == False:
flag = 1
self.Download(self.base_url + '/secured/serial/generate.php?env=' + self.os + '&id2=' + macad, filepath)
with open(filepath, 'r') as f:
ser = f.readline()
if len(ser) != 16:
self.message('End up with error 1500.', 'ERROR')
shutil.rmtree(self.profile)
exit()
return
if flag:
self.message(ser)
except:
self.message('This device is not supported', 'ERROR')
return 'ERROR'
return ser
def play_stream(self, url, name, ref = ''):
player = xbmc.Player()
if player.isPlaying():
player.stop()
if ref is not None and ref != '':
url = url + '|referer=' + ref
listitem = xbmcgui.ListItem(label=str(name), iconImage='DefaultVideo.png', thumbnailImage=xbmc.getInfoImage('ListItem.Thumb'), path=url)
listitem.setInfo(type='video', infoLabels={'Title': name,
'Path': url})
xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(str(url), listitem)
return
def get_category(self, url, name, iconimage, fanart, origurl, shareurl, thumb, guid, mode, page, index, ref):
print 'nothing to say........'
data = self.cache(self.base_url + '/secured/status.php?' + self.security_url)
if data == '':
exit()
if 'Account is active' not in data:
self.message(data)
exit()
elif mode == None:
print 'nothing to say........'
self.getSources()
elif mode == 1:
print 'nothing to say........'
self.getData(url, fanart)
elif mode == 2:
print 'nothing to say........'
self.getChannelItems(name, url, fanart)
elif mode == 3:
print 'nothing to say........'
self.getSubChannelItems(name, url, fanart)
elif mode == 4:
print 'nothing to say........'
self.getFavorites()
elif mode == 5:
print 'nothing to say........'
try:
name = name.split('\\ ')[1]
except:
pass
try:
name = name.split(' - ')[0]
except:
pass
self.addFavorite(name, url, iconimage, fanart)
elif mode == 6:
print 'nothing to say........'
try:
name = name.split('\\ ')[1]
except:
pass
try:
name = name.split(' - ')[0]
except:
pass
self.rmFavorite(name)
elif mode == 7:
print 'nothing to say........'
self.addSource(url)
elif mode == 8:
print 'nothing to say........'
self.rmSource(name)
elif mode == 11:
print 'nothing to say........'
self.addSource(url)
elif mode == 12:
print 'nothing to say........'
elif mode == self.PLUGIN_MODE_PLAY_YT_VIDEO:
self.play_youtube_video(guid, name)
elif mode == self.PLUGIN_MODE_QUERY_DB:
self.build_search_directory('querydb')
elif mode == self.PLUGIN_MODE_QUERY_YT:
self.build_search_directory('queryyt')
elif mode == self.PLUGIN_MODE_QUERY_DM:
self.build_search_directory('querydm')
elif mode == self.PLUGIN_MODE_BUILD_YT_USER:
self.build_user_directory('id')
elif mode == self.PLUGIN_MODE_BUILD_DM_USER:
self.build_user_directory('dmid')
elif mode == self.PLUGIN_MODE_BUILD_YT_FAV:
self.build_ytuser_favs_directory()
elif mode == self.PLUGIN_MODE_PLAY_PLAYLIST:
self.play_playlist(url, index)
elif mode == self.PLUGIN_MODE_PLAY_SLIDESHOW:
self.play_picture_slideshow(url, name)
elif mode == self.PLUGIN_MODE_PLAY_STREAM:
self.play_stream(url, name)
elif mode == self.PLUGIN_MODE_OPEN_SETTINGS:
self.open_settings()
elif mode == self.PLUGIN_MODE_PLAY_4SHARED:
self.play_fourshared(url, name)
elif mode == self.PLUGIN_MODE_DOWNLOAD:
self.download(url, name, guid, True)
elif mode == self.PLUGIN_MODE_DOWNLOAD_ALL:
self.download_all(origurl, name)
elif mode == self.PLUGIN_MODE_QUERY:
self.custom_search_directory(url, name)
elif mode == self.PLUGIN_MODE_OPEN_DOWNLOADS:
self.open_download_dir()
elif mode == self.PLUGIN_MODE_PLAY_DESISTREAM:
self.play_desistreamtv(name, url, thumb)
elif mode == self.PLUGIN_MODE_PLAY_VUXMLSTREAM:
self.playVuxmlStream(name, url, thumb)
elif mode == self.PLUGIN_MODE_PLAY_DAGSTREAM:
self.playDagStream(name, url, thumb)
elif mode == self.PLUGIN_MODE_OPEN_PLUGIN:
self.open_plugin(url)
elif mode == self.PLUGIN_MODE_PLAY_EBOUND:
self.playEboundStream(name, url, thumb, ref)
elif mode == self.PLUGIN_MODE_PLAY_URLRESOLVER:
self.play_urlresolved_stream(url, name)
elif mode == self.PLUGIN_MODE_PLAY_YUPP:
self.play_yupp(url, name)
elif mode == self.PLUGIN_MODE_PLAY_IPTVEXPRESS:
self.play_iptvexpress(url, name)
elif mode == self.PLUGIN_MODE_PLAY_BILLIONUPLOADS:
self.play_billion_uploads(url, name)
elif mode == self.PLUGIN_MODE_PLAY_NOVAMOV:
self.play_novamov(url, guid)
elif mode == self.PLUGIN_MODE_VOD or mode == self.PLUGIN_MODE_VOD2:
self.getVOD(url)
if mode == self.PLUGIN_MODE_VOD:
xbmc.executebuiltin('Container.SetViewMode(502)')
else:
xbmc.executebuiltin('Container.SetViewMode(500)')
return