Skip to content

Commit

Permalink
fixes 9anime
Browse files Browse the repository at this point in the history
Fixes:
- 9anime fixes

Changes:
- Message when no library defined for Download Options
  • Loading branch information
coder-alpha committed Nov 29, 2017
1 parent 3b3861c commit 046cf7d
Show file tree
Hide file tree
Showing 4 changed files with 275 additions and 77 deletions.
3 changes: 3 additions & 0 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,9 @@ def DownloadOptions(session, refresh=0, **kwargs):

title_msg = 'Library:%s | Type:%s | Path:%s | Enabled:%s' % (section[2], type.title(), section[3], common.GetEmoji(type=bool, mode='simple', session=session))
oc.add(DirectoryObject(title = title_msg, key = Callback(SetDownloadChoice, session=session, key=section[0], title=section[2], type=type, path=section[3], bool=bool)))

if len(oc) == 0:
return MC.message_container('No Library found', 'No library was found ! Please define a Movie and TV-Show library first !')

oc.add(DirectoryObject(
key = Callback(DownloadOptions, session=session, refresh=int(refresh)+1),
Expand Down
2 changes: 1 addition & 1 deletion Contents/Code/common.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
################################################################################
TITLE = "FMoviesPlus"
VERSION = '0.51' # Release notation (x.y - where x is major and y is minor)
VERSION = '0.52' # Release notation (x.y - where x is major and y is minor)
TAG = ''
GITHUB_REPOSITORY = 'coder-alpha/FMoviesPlus.bundle'
PREFIX = "/video/fmoviesplus"
Expand Down
222 changes: 176 additions & 46 deletions Contents/Code/fmovies.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def setTokenCookie(serverts=None, use_debug=False, reset=False, dump=False, quie
else:
if serverts == None:
serverts = str(((int(time.time())/3600)*3600))

UA = common.client.randomagent()

headersS = {'X-Requested-With': 'XMLHttpRequest'}
Expand Down Expand Up @@ -435,7 +435,7 @@ def setTokenCookie(serverts=None, use_debug=False, reset=False, dump=False, quie
common.CACHE_COOKIE.append(cookie_dict)

return cookie

def decodeAndParse(token, use_debug=False, use_https_alt=False, quiet=True):
# dec = common.jsfdecoder.JSFDecoder(common.client.b64decode(token)).ca_decode()
# dec = dec.split('reqkey=')
Expand Down Expand Up @@ -585,6 +585,28 @@ def get_sources(url, key, use_debug=True, serverts=0, myts=0, use_https_alt=Fals
return magic_url, isTargetPlay, error, host_type, subtitle
referer = url
serverts = str(serverts)

try:
myts1 = serverts
serverts = str(int(myts1))
except:
if use_debug:
Log("Server-TS is encoded !")
try:
b, resp = decode_ts(myts1)
if b == False:
raise Exception('Could not decode ts')
else:
serverts = str(int(resp))
if use_debug:
Log("Server-TS decoded !")
except:
Log("Server-TS could not be decoded !")
if common.control.setting('9animeserverts') != None:
serverts = str(common.control.setting('9animeserverts'))
if use_debug:
Log("Server-TS from provider plugin !")

T_BASE_URL = BASE_URL
T_BASE_URL = 'https://%s' % common.client.geturlhost(url)
is9Anime = True if common.ANIME_KEY in url else False
Expand Down Expand Up @@ -631,54 +653,110 @@ def get_sources(url, key, use_debug=True, serverts=0, myts=0, use_https_alt=Fals
#print result
result = json.loads(result)

if 'error' in result:
grabber = None
error = result['error']
elif result['target'] != "":
grabber = result['target']
b, resp = decode_t(grabber, -18, is9Anime)
if b == False:
raise ValueError(resp)
grabber = resp
isTargetPlay = True
subtitle = result['subtitle']
else:
grabber = result['grabber']
grab_data = grabber
grabber_url = urlparse.urljoin(BASE_URL, GRABBER_API)

if '?' in grabber:
grab_data = grab_data.split('?')
grabber_url = grab_data[0]
grab_data = grab_data[1]
if is9Anime == True:
if 'error' in result:
grabber = None
error = result['error']
elif result['target'] == "-":
grabber = result['grabber']
grab_data = grabber
grabber_url = urlparse.urljoin(T_BASE_URL, GRABBER_API)

grab_server = str(urlparse.parse_qs(grab_data)['server'][0])

b, resp = decode_t(result['params']['token'], -18, is9Anime)
if b == False:
raise ValueError(resp)
token = resp
b, resp = decode_t(result['params']['options'], -18, is9Anime)
if b == False:
raise ValueError(resp)
options = resp

grab_query = {'ts':serverts, grabber_url:'','id':result['params']['id'],'server':grab_server,'mobile':'0','token':token,'options':options}
tk = get_token(grab_query, token_error, is9Anime)
if '?' in grabber:
grab_data = grab_data.split('?')
grabber_url = grab_data[0]
grab_data = grab_data[1]

print grab_data
grab_server = str(urlparse.parse_qs(grab_data)['server'][0])

b, resp = decode_t(result['params']['token'], -18, is9Anime)
if b == False:
raise Exception(resp)
token = resp
b, resp = decode_t(result['params']['options'], -18, is9Anime)
if b == False:
raise Exception(resp)
options = resp

grab_query = {'ts':serverts, grabber_url:'','id':result['params']['id'],'server':grab_server,'mobile':'0','token':token,'options':options}
tk = get_token(grab_query, token_error, is9Anime)

if tk == None:
raise ValueError('video token algo')
grab_info = {'token':token,'options':options}
del query['server']
query.update(grab_info)
query.update(tk)
if tk == None:
raise Exception('video token algo')
grab_info = {'token':token,'options':options}
del query['server']
query.update(grab_info)
query.update(tk)

subtitle = result['subtitle']
if subtitle==None or len(subtitle) == 0:
subtitle = None

if '?' in grabber:
grabber += '&' + urllib.urlencode(query)
else:
grabber += '?' + urllib.urlencode(query)

subtitle = result['subtitle']
if '?' in grabber:
grabber += '&' + urllib.urlencode(query)
if grabber!=None and not grabber.startswith('http'):
grabber = 'http:'+grabber
else:
grabber += '?' + urllib.urlencode(query)
grabber = result['target']
b, resp = decode_t(grabber, -18, is9Anime)
if b == False:
raise ValueError(resp)
grabber = resp
isTargetPlay = True
subtitle = result['subtitle']
else:
if 'error' in result:
grabber = None
error = result['error']
elif result['target'] != "":
grabber = result['target']
b, resp = decode_t(grabber, -18, is9Anime)
if b == False:
raise ValueError(resp)
grabber = resp
isTargetPlay = True
subtitle = result['subtitle']
else:
grabber = result['grabber']
grab_data = grabber
grabber_url = urlparse.urljoin(T_BASE_URL, GRABBER_API)

if '?' in grabber:
grab_data = grab_data.split('?')
grabber_url = grab_data[0]
grab_data = grab_data[1]

grab_server = str(urlparse.parse_qs(grab_data)['server'][0])

b, resp = decode_t(result['params']['token'], -18, is9Anime)
if b == False:
raise ValueError(resp)
token = resp
b, resp = decode_t(result['params']['options'], -18, is9Anime)
if b == False:
raise ValueError(resp)
options = resp

grab_query = {'ts':serverts, grabber_url:'','id':result['params']['id'],'server':grab_server,'mobile':'0','token':token,'options':options}
tk = get_token(grab_query, token_error, is9Anime)

if tk == None:
raise ValueError('video token algo')
grab_info = {'token':token,'options':options}
del query['server']
query.update(grab_info)
query.update(tk)

subtitle = result['subtitle']
if '?' in grabber:
grabber += '&' + urllib.urlencode(query)
else:
grabber += '?' + urllib.urlencode(query)

if subtitle == None or len(subtitle) == 0:
subtitle = None

Expand Down Expand Up @@ -734,7 +812,7 @@ def decode_t(t, i, is9Anime=False, **kwargs):

try:
if is9Anime == True:
return True, t
return decode_t2(t)
for n in range(0, len(t)):
if n==0 and t[n] == '.':
pass
Expand All @@ -753,6 +831,58 @@ def decode_t(t, i, is9Anime=False, **kwargs):
except Exception as e:
Log("fmovies.py > decode_t > %s" % e)
return False, 'Error in decoding val'

def decode_t2(t):
r = ""
e_s = 'abcdefghijklmnopqrstuvwxyz'
r_s = 'acegikmoqsuwybdfhjlnprtvxz'
try:
if t[0] == '-' and len(t) > 1:
t = t[1:]
for n in range(0, len(t)):
if n == 0 and t[n] == '-':
pass
else:
s = False
for ix in range(0, len(r_s)):
if t[n] == r_s[ix]:
r += e_s[ix]
s = True
break
if s == False:
r += t[n]

missing_padding = len(r) % 4
if missing_padding != 0:
r += b'='* (4 - missing_padding)
r = common.client.b64decode(r)
return True, r
except Exception as e:
False, 'Error in decoding'

def decode_ts(t):
r = ""
e_s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
r_s = 'ACEGIKMOQSUWYBDFHJLNPRTVXZ'
try:
if len(t) > 1:
for n in range(0, len(t)):
s = False
for ix in range(0, len(r_s)):
if t[n] == r_s[ix]:
r += e_s[ix]
s = True
break
if s == False:
r += t[n]

missing_padding = len(r) % 4
if missing_padding != 0:
r += b'='* (4 - missing_padding)
r = common.client.b64decode(r)
return True, r
except Exception as e:
False, 'Error in decoding'

def get_token(n, token_error=False, is9Anime=False, **kwargs):
try:
Expand Down
Loading

0 comments on commit 046cf7d

Please sign in to comment.