Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
coder-alpha committed Nov 3, 2016
2 parents e47174f + cd8b186 commit 9396ebb
Show file tree
Hide file tree
Showing 300 changed files with 74,028 additions and 612 deletions.
1,518 changes: 1,079 additions & 439 deletions Contents/Code/__init__.py

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Contents/Code/common.py
@@ -1,10 +1,12 @@
################################################################################
TITLE = "cCloud TV | A Community based Social IPTV Service for Live TV, Movies, TV Shows & Radio"
VERSION = '0.19' # Release notation (x.y - where x is major and y is minor)
VERSION = '0.20' # Release notation (x.y - where x is major and y is minor)
GITHUB_REPOSITORY = 'coder-alpha/CcloudTv.bundle'
PREFIX = "/video/ccloudtv"
################################################################################

USER_AGENT = 'Mozilla5.0'

COUNTRY_ARRAY_LIST = {'afghanistan': 'af',
'albania': 'al',
'algeria': 'dz',
Expand Down
86 changes: 72 additions & 14 deletions Contents/Code/common_fnc.py
@@ -1,4 +1,5 @@
import common, urllib2, string, random, base64, datetime, redirect_follower
import os, urllib2, string, random, base64, datetime
import common, redirect_follower, playback, common

global_request_timeout = 10

Expand All @@ -9,12 +10,36 @@
@route(common.PREFIX + '/gethttpstatus')
def GetHttpStatus(url):
try:
conn = urllib2.urlopen(url, timeout = global_request_timeout)
resp = str(conn.getcode())
except StandardError:
headers = {'User-Agent': common.USER_AGENT,
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
'Accept-Encoding': 'none',
'Accept-Language': 'en-US,en;q=0.8',
'Connection': 'keep-alive',
'Referer': url}

if '|' in url:
url_split = url.split('|')
url = url_split[0]
headers['Referer'] = url
for params in url_split:
if '=' in params:
param_split = params.split('=')
param = param_split[0].strip()
param_val = urllib2.quote(param_split[1].strip(), safe='/=&')
headers[param] = param_val

if 'http://' in url or 'https://' in url:
req = urllib2.Request(url, headers=headers)
conn = urllib2.urlopen(req, timeout=global_request_timeout)
resp = str(conn.getcode())
else:
resp = '200'
except Exception as e:
resp = '0'
if Prefs['debug']:
Log(url +' : HTTPResponse = '+ resp)
if Prefs['debug']:
Log('Error common_fnc.py > GetHttpStatus: ' + str(e))
Log(url +' : HTTPResponse = '+ resp)
return resp


Expand All @@ -26,10 +51,11 @@ def FollowRedirectGetHttpStatus(url):
response = redirect_follower.GetRedirect(url,global_request_timeout)
if response <> None:
resp = str(response.getcode())
except:
except Exception as e:
resp = '0'
if Prefs['debug']:
Log(url +' : HTTPResponse = '+ resp)
if Prefs['debug']:
Log('Error common_fnc.py > FollowRedirectGetHttpStatus: ' + str(e))
Log(url +' : HTTPResponse = '+ resp)
return resp

####################################################################################################
Expand All @@ -44,10 +70,10 @@ def GetRedirector(url):
#page = urllib2.urlopen(url, timeout = global_request_timeout)
#redirectUrl = page.geturl()
redirectUrl = GetRedirectingUrl(url)
except:
except Exception as e:
if Prefs['debug']:
Log('Error common_fnc.py > GetRedirector: ' + str(e))
redirectUrl = url
if Prefs['debug'] and url != redirectUrl:
Log(url + "Redirecting to : " + redirectUrl)
return redirectUrl

####################################################################################################
Expand All @@ -67,6 +93,12 @@ def GetRedirectingUrl(url):
#Log("Redirecting url ----- : " + redirectUrl)
return redirectUrl

####################################################################################################

@route(common.PREFIX + '/showmessage')
def ShowMessage(title, message):
return ObjectContainer(header=title, message=message, title1=title)

@route(common.PREFIX + '/id_generator')
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
Expand Down Expand Up @@ -117,6 +149,9 @@ def getDeviceName():
else:
return 'UnknownPlexDeviceName'

def getPlexHeaders():
return str(Request.Headers)

####################################################################################################
# search array item's presence in string
@route(common.PREFIX + "/arrayitemsinstring")
Expand All @@ -135,16 +170,36 @@ def ArrayItemsInString(arr, mystr):
# https://github.com/Cigaras/IPTV.bundle
#
# Copyright © 2013-2015 Valdas Vaitiekaitis
# Modified by CA, 2016
#
def GetAttribute(text, attribute, delimiter1 = '="', delimiter2 = '"'):
x = text.find(attribute)
if x > -1:
y = text.find(delimiter1, x + len(attribute)) + len(delimiter1)
z = text.find(delimiter2, y)
if z == -1:
z = len(text)
return unicode(text[y:z].strip())

retStr = unicode(text[y:z].strip())
if attribute.lower() != 'tvg-logo' and 'http' in retStr:
y = text.find('=', x + len(attribute)) + len(' ')
z = text.find(' ', y)
if z == -1:
z = len(text)
retStr = unicode(text[y:z].strip())

if '=' in retStr:
retStr = retStr.split('=')[1]
if ',' in retStr:
retStr = retStr.split(',')[0]
return retStr
else:
return ''

#######################################################################################################
# url decode
def urldecode(string):
return urllib2.unquote(string)

#######################################################################################################
# base64 decode
Expand Down Expand Up @@ -172,6 +227,7 @@ def getRawPastebinLink(url):
# Gets the raw Pastebin link
def getDatePastebinLink(content):
try:
content = content.strip('Untitled. a guest ')
date = str(content.split('<b>')[0].strip())
if 'hour' in date:
dt = date.split(' ')
Expand All @@ -198,4 +254,6 @@ def month_string_to_number(string):
'nov':11,
'dec':12
}
return m[string]
return m[string]

#######################################################################################################

0 comments on commit 9396ebb

Please sign in to comment.