Skip to content

Instantly share code, notes, and snippets.

@ypchen
Last active April 3, 2021 15:27
Show Gist options
  • Save ypchen/ebb973eae84b4001ebe82229164610ea to your computer and use it in GitHub Desktop.
Save ypchen/ebb973eae84b4001ebe82229164610ea to your computer and use it in GitHub Desktop.
Auto-update for plugin.video.hdp_ims
def my_gist_hash ():
return 'ebb973eae84b4001ebe82229164610ea'
def my_addon_version ():
return '1.18.2'
def my_version ():
return my_addon_version() + '-gist-r9'
# priv: revision 24
# If the version number mismatches, overwrite gist_hash in settings.xml
if (my_addon_version() != xbmcaddon.Addon().getAddonInfo('version')):
addon.setSetting('gist_hash', version_gist_hash[xbmcaddon.Addon().getAddonInfo('version')])
def get_link_contents (url, data_to_post=None, http_header=None, user_agent=None, url_redir=False):
name = 'get_link_contents'
#xbmc.log('[%s] %s' % (name, 'url={' + url + '}'), xbmc.LOGNOTICE)
contents = ''
if data_to_post is None:
request = urllib2.Request(url)
else:
request = urllib2.Request(url, data_to_post)
if user_agent is None:
user_agent = 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.04 Chromium/14.0.825.0 Chrome/14.0.825.0 Safari/535.1'
request.add_header('User-Agent', user_agent)
if http_header is not None:
for key, val in http_header.iteritems():
request.add_header(key, val)
try:
#xbmc.log('[%s] %s' % (name, 'before -- response = urllib2.urlopen(request)'), xbmc.LOGNOTICE)
response = urllib2.urlopen(request)
#xbmc.log('[%s] %s' % (name, 'response.code={' + str(response.getcode()) + '}'), xbmc.LOGNOTICE)
if (200 == response.getcode()):
if (url_redir):
# not sure why 200 (should be 302 here)
url_redir = response.geturl()
else:
contents = response.read()
#except urllib2.HTTPError, e:
#xbmc.log('[%s] %s' % (name, 'HTTPError={' + str(e.code) + '}'), xbmc.LOGNOTICE)
#except urllib2.URLError, e:
#xbmc.log('[%s] %s' % (name, 'URLError={' + str(e.reason) + '}'), xbmc.LOGNOTICE)
#except httplib.HTTPException, e:
#xbmc.log('[%s] %s' % (name, 'HTTPException'), xbmc.LOGNOTICE)
#except Exception as e:
#xbmc.log('[%s] %s' % (name, 'e={' + str(e) + '}'), xbmc.LOGNOTICE)
finally:
#xbmc.log('[%s] %s' % (name, 'finally'), xbmc.LOGNOTICE)
if (url_redir):
return url_redir
else:
if (0 < len(contents)):
#xbmc.log('[%s] %s' % (name, 'finally -- if (0 < len(contents))'), xbmc.LOGNOTICE)
return contents
else:
# a very bad plan B
#xbmc.log('[%s] %s' % (name, 'finally -- if (0 >= len(contents))'), xbmc.LOGNOTICE)
import subprocess
prog_curl = ''
if not addon.getSetting('curl'):
prog_curl = '/usr/bin/curl'
xbmc.log('[%s] %s' % (name, 'if not addon.getSetting(curl): [' + prog_curl + ']'), xbmc.LOGNOTICE)
else:
prog_curl = addon.getSetting('curl')
xbmc.log('[%s] %s' % (name, 'else (getSetting(curl) ok): [' + prog_curl + ']'), xbmc.LOGNOTICE)
return subprocess.check_output([prog_curl, '--output', '-', url])
# Unknown: JB, Qw
gimycc_episode_url_code_dict = {'JT':'', 'JC':'+', 'JD':',', 'JE':'-', 'JF':'.', 'JG':'/', 'Mw':'0', 'Mx':'1', 'My':'2', 'Mz':'3', 'M0':'4', 'M1':'5', 'M2':'6', 'M3':'7', 'M4':'8', 'M5':'9', 'NB':':', 'NC':';', 'ND':'<', 'NE':'=', 'NF':'>', 'NG':'?', 'VC':'[', 'VD':'\\', 'VE':']', 'VF':'^', 'VG':'_', 'Yx':'a', 'Yy':'b', 'Yz':'c', 'Y0':'d', 'Y1':'e', 'Y2':'f', 'Y3':'g', 'Y4':'h', 'Y5':'i', 'ZB':'j', 'ZC':'k', 'ZD':'l', 'ZE':'m', 'ZF':'n', 'ZG':'o', 'cw':'p', 'cx':'q', 'cy':'r', 'cz':'s', 'c0':'t', 'c1':'u', 'c2':'v', 'c3':'w', 'c4':'x', 'c5':'y', 'dB':'z', 'Qx':'A', 'Qy':'B', 'Qz':'C', 'Q0':'D', 'Q1':'E', 'Q2':'F', 'Q3':'G', 'Q4':'H', 'Q5':'I', 'RB':'J', 'RC':'K', 'RD':'L', 'RE':'M', 'RF':'N', 'RG':'O', 'Uw':'P', 'Ux':'Q', 'Uy':'R', 'Uz':'S', 'U0':'T', 'U1':'U', 'U2':'V', 'U3':'W', 'U4':'X', 'U5':'Y', 'VB':'Z'}
def gimycc_episode (params):
name = 'gimycc_episode'
link_orig = params['link']
html = get_link_contents(link_orig)
if ('' == html):
return []
htmlToExplode = str_between(html, 'player_data={', '</script>')
# https://stackoverflow.com/questions/9475241/split-string-every-nth-character
link = ''
line = str_between(htmlToExplode, '"url":"', '"')
exception_num = 0
n = 2
lineSplit = [line[i:i+n] for i in range(0, len(line), n)]
for s in lineSplit:
try:
link = link + gimycc_episode_url_code_dict[s]
except KeyError:
link = link + '?'+s+'#'
exception_num += 1
if (0 < exception_num):
xbmc.log('[%s] %s' % (name, 'if (0 < exception_num): [' + link_orig + '#%#' + link + ']'), xbmc.LOGERROR)
playitem = xbmcgui.ListItem(path=link)
playitem.setProperty('inputstreamaddon','inputstream.adaptive')
playitem.setProperty('inputstream.adaptive.manifest_type','hls')
playitem.setMimeType('application/vnd.apple.mpegurl')
playitem.setContentLookup(False)
xbmcplugin.setResolvedUrl(addon_handle, True, playitem)
# -- kubo --
kubo_filter_insert_at = '2020'
kubo_filter_insert_this = '2021'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment