Skip to content

Instantly share code, notes, and snippets.

@ypchen
Last active November 13, 2021 13:48
Show Gist options
  • Save ypchen/a056ebf6ae5c46b2989a549f62702e3c to your computer and use it in GitHub Desktop.
Save ypchen/a056ebf6ae5c46b2989a549f62702e3c to your computer and use it in GitHub Desktop.
Auto-update for plugin.video.hdp_ims
def my_gist_hash ():
return 'a056ebf6ae5c46b2989a549f62702e3c'
def my_addon_version ():
return '1.18.3'
def my_version ():
return my_addon_version() + '-gist-r8'
# priv: revision 45
# 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')])
#### Quickfix code ####
# ----- ims -----
sites = [
{
'title': '劇迷 gimy.cc',
'action': 'list_items',
'callback': 'gimycc_id()',
'isFolder': True,
'siteVisible': 'siteVisible = True'
},
{
'title': '劇迷 gimytv.com',
'action': 'list_items',
'callback': 'gimytv_id()',
'isFolder': True,
'siteVisible': 'siteVisible = True'
},
{
'title': '劇迷 135mov.com / gimyvod.cc',
'action': 'list_items',
'callback': 'mov135_id()',
'isFolder': True,
'siteVisible': 'siteVisible = True'
},
{
'title': '酷播 99KUBO',
'action': 'list_items',
'callback': 'kubo_id()',
'isFolder': True,
'siteVisible': 'siteVisible = True'
},
]
# ----- ims -----
# -- gimy.cc --
gimycc_sources_str1 = '<ul class="nav nav-tabs'
gimycc_sources_str2 = '</ul>'
gimycc_sources_str3 = '"tabslist"'
gimycc_sources_str4 = '"tab">'
gimycc_sources_str5 = '</a>'
gimycc_sources_str6 = 'href="#'
gimycc_sources_str7 = '"'
gimycc_sources_str8 = '<div class="tab-content '
gimycc_sources_str9 = '<div class="stui-pannel-box">'
def gimycc_sources (params):
name = 'gimycc_sources()'
xbmc.log('[%s] %s' % (name, 'link={' + params['link'] + '}'), xbmc.LOGNOTICE)
html = get_link_contents(params['link'])
if ('' == html):
return []
htmlToExplode = str_between(html, gimycc_sources_str1, gimycc_sources_str2)
videos = htmlToExplode.split(gimycc_sources_str3)
videos.pop(0)
items = []
items.append({'title': '選擇來源:', 'link': '', 'action': '', 'callback': '', 'isFolder': False})
for video in videos:
title = str_between(video, gimycc_sources_str4, gimycc_sources_str5).strip()
playlist_id = str_between(video, gimycc_sources_str6, gimycc_sources_str7).strip()
items.append({'title': title, 'link': params['link'], 'action': 'list_items', 'callback': 'gimycc_episodes(params)', 'isFolder': True, 'playlist_id': playlist_id, 'playlist_title': title, 'html': str_between(html, gimycc_sources_str8, gimycc_sources_str9)})
return items
gimycc_episodes_str_default_id = 'playlist1'
gimycc_episodes_str1 = ''
gimycc_episodes_str2 = '</ul>'
gimycc_episodes_str3 = 'id="'
gimycc_episodes_str4 = '"'
gimycc_episodes_str5 = '<li'
gimycc_episodes_str6 = 'https://gimy.cc'
gimycc_episodes_str7 = 'title="'
gimycc_episodes_str8 = '"'
gimycc_episodes_str9 = 'href="'
gimycc_episodes_strA = '"'
def gimycc_episodes (params):
name = 'gimycc_episodes()'
data = json.loads(base64.b64decode(params['data']), 'utf-8')
try:
playlist_id = data['playlist_id']
playlist_title = data['playlist_title']
except:
playlist_id = gimycc_episodes_str_default_id
playlist_title = '預設'
# xbmc.log('[%s] %s' % (name, 'playlist_id={' + playlist_id + '}' + '; playlist_title={' + playlist_title + '}'), xbmc.LOGNOTICE)
html = data['html']
if (not gimycc_episodes_str1):
local_gimycc_episodes_str1 = gimycc_episodes_str3 + playlist_id + gimycc_episodes_str4
else:
local_gimycc_episodes_str1 = gimycc_episodes_str1
htmlToExplode = str_between(html, local_gimycc_episodes_str1, gimycc_episodes_str2)
videos = htmlToExplode.split(gimycc_episodes_str5)
videos.pop(0)
siteURLprefix = gimycc_episodes_str6
items = []
for video in videos:
title = playlist_title + ': ' + str_between(video, gimycc_episodes_str7, gimycc_episodes_str8).strip()
link = siteURLprefix + str_between(video, gimycc_episodes_str9, gimycc_episodes_strA).strip()
# xbmc.log('[%s] %s' % (name, 'link={' + link + '}'), xbmc.LOGNOTICE)
link = build_url_dict({'action': 'gimycc_episode', 'link': link})
items.append({'title': title, 'link': link, 'isFolder': False, 'IsPlayable': 'True'})
return items
# -- gimy.cc --
# -- gimytv.com --
gimytv_site = 'gimytv.com'
def gimytv_id ():
# hard-coded top level menu items
# link is the -id-- in the search criteria
return [
{
'title': '電視劇', 'link': 'https://' + gimytv_site + '/genre/2-----------.html', 'action': 'list_items',
'callback': 'gimytv_drama_category(params)', 'isFolder': True
},
{
'title': '電影', 'link': 'https://' + gimytv_site + '/genre/1-----------.html', 'action': 'list_items',
'callback': 'gimytv_movie_category(params)', 'isFolder': True
},
{
'title': '動漫', 'link': 'https://' + gimytv_site + '/genre/4-----------.html', 'action': 'list_items',
'callback': 'gimytv_area(params)', 'isFolder': True
},
{
'title': '綜藝', 'link': 'https://' + gimytv_site + '/genre/3-----------.html', 'action': 'list_items',
'callback': 'gimytv_area(params)', 'isFolder': True
}
]
gimytv_filter_URL_prefix = 'https://' + gimytv_site
gimytv_videos_strE = 'https://' + gimytv_site
gimytv_episodes_str4 = 'https://' + gimytv_site
gimytv_sources_str1 = '-- end 詳細信息--'
gimytv_sources_str2 = '-- 下載地址--'
gimytv_sources_str3 = '<h3 '
gimytv_sources_str4 = '"title">'
gimytv_sources_str5 = '</h3>'
gimytv_sources_str6 = '"title">'
gimytv_sources_str7 = '</h3>'
gimytv_sources_str8 = '-- end 詳細信息--'
gimytv_sources_str9 = '-- 下載地址--'
gimytv_sources_strA = '-->'
gimytv_sources_strB = '!--'
gimytv_episodes_str_default_id = 'playlist1'
gimytv_episodes_str1 = 'fa-sort'
gimytv_episodes_str2 = '</ul>'
gimytv_episodes_str3 = '<li '
gimytv_episodes_str4 = 'https://' + gimytv_site
gimytv_episodes_str5 = '.html">'
gimytv_episodes_str6 = '<'
gimytv_episodes_str7 = 'href="'
gimytv_episodes_str8 = '"'
# -- gimytv.com --
# -- 135mov.com --
mov135_site = 'gimyvod.cc'
def mov135_id ():
# hard-coded top level menu items
# link is the -id-- in the search criteria
return [
{
'title': '電視電影', 'link': 'http://' + mov135_site + '/list-select-id-16-type--area--year--star--state--order-addtime.html', 'action': 'list_items',
'callback': 'mov135_channel(params)', 'isFolder': True
},
{
'title': '動漫', 'link': 'http://' + mov135_site + '/list-select-id-3-type--area--year--star--state--order-addtime.html', 'action': 'list_items',
'callback': 'mov135_area(params)', 'isFolder': True
},
{
'title': '綜藝', 'link': 'http://' + mov135_site + '/list-select-id-4-type--area--year--star--state--order-addtime.html', 'action': 'list_items',
'callback': 'mov135_area(params)', 'isFolder': True
}
]
mov135_filter_URL_prefix = 'http://' + mov135_site
mov135_filter_insert_all = '全部'
mov135_filter_insert_at = '2020'
mov135_filter_insert_this = '2021'
mov135_filter_insert_pre = '-year-'
mov135_filter_insert_post = '-star-'
mov135_filter_str1 = '</dd>'
mov135_filter_str2 = '<a '
mov135_filter_str3 = '>'
mov135_filter_str4 = '</a'
mov135_filter_str5 = 'href="'
mov135_filter_str6 = '"'
def mov135_filter (params, url, explodeStart, nextCallback):
name = 'mov135_filter()'
xbmc.log('[%s] %s' % (name, '[' + explodeStart + ']; link={' + url + '}'), xbmc.LOGNOTICE)
html = get_link_contents(url)
if ('' == html):
return []
htmlToExplode = str_between(html, explodeStart, mov135_filter_str1)
videos = htmlToExplode.split(mov135_filter_str2)
videos.pop(0)
siteURLprefix = mov135_filter_URL_prefix
items = []
prevTitle = ''
for video in videos:
title = str_between(video, mov135_filter_str3, mov135_filter_str4).strip()
# Special for mov135 -- BEGIN
if (('動漫' != title) and ('綜藝' != title)):
# Special for mov135 -- END
# order asc
if ((prevTitle == mov135_filter_insert_at) and (title == mov135_filter_insert_all)):
items.append({'title': mov135_filter_insert_this, 'link': link.replace(mov135_filter_insert_pre + mov135_filter_insert_at + mov135_filter_insert_post, mov135_filter_insert_pre + mov135_filter_insert_this + mov135_filter_insert_post), 'action': 'list_items', 'callback': nextCallback, 'isFolder': True})
link = siteURLprefix + str_between(video, mov135_filter_str5, mov135_filter_str6).strip()
# order desc
if ((prevTitle == mov135_filter_insert_all) and (title == mov135_filter_insert_at)):
items.append({'title': mov135_filter_insert_this, 'link': link.replace(mov135_filter_insert_pre + mov135_filter_insert_at + mov135_filter_insert_post, mov135_filter_insert_pre + mov135_filter_insert_this + mov135_filter_insert_post), 'action': 'list_items', 'callback': nextCallback, 'isFolder': True})
items.append({'title': title, 'link': link, 'action': 'list_items', 'callback': nextCallback, 'isFolder': True})
prevTitle = title
return items
def mov135_channel (params):
return mov135_filter (params, params['link'], '>頻道:', 'mov135_year(params)')
def mov135_area (params):
return mov135_filter (params, params['link'], '>地區:', 'mov135_year(params)')
def mov135_year (params):
return mov135_filter (params, params['link'], '>年代:', 'mov135_videos(params)')
mov135_videos_str1 = 'class="pagination pagination'
mov135_videos_str2 = '</ul>'
mov135_videos_str3 = 'disabled">'
mov135_videos_str4 = '</li>'
mov135_videos_str5 = '">'
mov135_videos_str6 = '</a>'
mov135_videos_str7 = '">...'
mov135_videos_str8 = '</a>'
#mov135_videos_str9 = 'pagegbk" data="p-'
#mov135_videos_strA = '">尾頁</a>'
mov135_videos_strB = '<ul class="thumbnail-group '
mov135_videos_strC = '</ul>'
mov135_videos_strD = '<li'
mov135_videos_strE = 'http://' + mov135_site
mov135_videos_strF = '</li>'
mov135_videos_strG = '&laquo;'
mov135_videos_strH = '">'
mov135_videos_strI = '</a'
mov135_videos_strJ = 'href="'
mov135_videos_strK = '"'
mov135_videos_strL = 'title="'
mov135_videos_strM = '"'
mov135_videos_strMx = '線上看'
mov135_videos_strN = 'href="'
mov135_videos_strO = '"'
mov135_videos_strP = 'data-original="'
mov135_videos_strQ = '"'
mov135_videos_strR = '"video-grade">'
mov135_videos_strS = '</span>'
mov135_videos_strT = '&raquo;'
mov135_videos_strU = '.html">'
mov135_videos_strV = '</a'
mov135_videos_strW = 'href="'
mov135_videos_strX = '"'
def mov135_videos (params):
name = 'mov135_videos()'
data = json.loads(base64.b64decode(params['data']), 'utf-8')
try:
page = int(data['page'])
except:
page = 1
html = get_link_contents(params['link'])
if ('' == html):
return []
pageHtmlAll = str_between(html, mov135_videos_str1, mov135_videos_str2)
pages = []
pages.append(str_between(str_between(pageHtmlAll, mov135_videos_str3, mov135_videos_str4), mov135_videos_str5, mov135_videos_str6))
pages.append(str_between(pageHtmlAll, mov135_videos_str7, mov135_videos_str8))
xbmc.log('[%s] %s' % (name, 'pages={' + pages[0] + ',' + pages[1] + '}'), xbmc.LOGNOTICE)
if ('' == pages[1]):
pages[1] = str(page)
pages[0] = pages[1]
htmlToExplode = str_between(html, mov135_videos_strB, mov135_videos_strC)
videos = htmlToExplode.split(mov135_videos_strD)
videos.pop(0)
siteURLprefix = mov135_videos_strE
items = []
items.append({'title': '第 [COLOR limegreen]' + pages[0] + '[/COLOR] 頁/共 [COLOR limegreen]' + pages[1] + '[/COLOR] 頁', 'link': '', 'action': '', 'callback': '', 'isFolder': False})
pageBlocks = pageHtmlAll.split(mov135_videos_strF)
if (page > 1):
for pageBlock in pageBlocks:
if (mov135_videos_strG == str_between(pageBlock, mov135_videos_strH, mov135_videos_strI).strip()):
link = siteURLprefix + str_between(pageBlock, mov135_videos_strJ, mov135_videos_strK).strip()
items.append({'title': '上一頁 (回第' + str(page-1) + '頁)', 'link': link, 'action': 'list_items', 'callback': 'mov135_videos(params)', 'isFolder': True, 'page': (page-1)})
break
for video in videos:
title = str_between(video, mov135_videos_strL, mov135_videos_strM).strip().replace(mov135_videos_strMx, '')
if ('' != title):
link = siteURLprefix + str_between(video, mov135_videos_strN, mov135_videos_strO).strip()
image = siteURLprefix + str_between(video, mov135_videos_strP, mov135_videos_strQ).strip()
note = ' -- (' + str_between(video, mov135_videos_strR, mov135_videos_strS).strip() + ')'
items.append({'title': title + note, 'link': link, 'action': 'list_items', 'callback': 'mov135_sources(params)', 'isFolder': True, 'image': image})
if (int(page) < int(pages[1])):
for pageBlock in pageBlocks:
if (mov135_videos_strT == str_between(pageBlock, mov135_videos_strU, mov135_videos_strV).strip()):
link = siteURLprefix + str_between(pageBlock, mov135_videos_strW, mov135_videos_strX).strip()
items.append({'title': '下一頁 (到第' + str(page+1) + '頁)', 'link': link, 'action': 'list_items', 'callback': 'mov135_videos(params)', 'isFolder': True, 'page': (page+1)})
break
return items
mov135_sources_str1 = '<ul class="detail-tab '
mov135_sources_str2 = '</ul>'
mov135_sources_str3 = '<li '
mov135_sources_str4 = 'tab">'
mov135_sources_str5 = '</a>'
mov135_sources_str6 = 'data-active="'
mov135_sources_str7 = '"'
mov135_sources_str8 = 'data-target="'
mov135_sources_str9 = '"'
mov135_sources_strA = '<div class="detail-content '
mov135_sources_strB = '</div>'
mov135_sources_strC = '<ul '
def mov135_sources (params):
name = 'mov135_sources()'
xbmc.log('[%s] %s' % (name, 'link={' + params['link'] + '}'), xbmc.LOGNOTICE)
html = get_link_contents(params['link'])
if ('' == html):
return []
ff_playurl = str_between(html, mov135_sources_str6, mov135_sources_str7)
htmlToExplode = str_between(html, mov135_sources_str1, mov135_sources_str2)
videos = htmlToExplode.split(mov135_sources_str3)
videos.pop(0)
htmlToExplodeDetail = str_between(html, mov135_sources_strA, mov135_sources_strB)
videosDetail = htmlToExplodeDetail.split(mov135_sources_strC)
videosDetail.pop(0)
items = []
items.append({'title': '選擇來源:', 'link': '', 'action': '', 'callback': '', 'isFolder': False})
current_video_index = 0
for video in videos:
title = str_between(video, mov135_sources_str4, mov135_sources_str5).strip()
playlist_id = str_between(video, mov135_sources_str8, mov135_sources_str9).strip().replace(ff_playurl, '')
items.append({'title': title, 'link': params['link'], 'action': 'list_items', 'callback': 'mov135_episodes(params)', 'isFolder': True, 'playlist_id': playlist_id, 'playlist_title': title, 'html': videosDetail[current_video_index]})
current_video_index = current_video_index + 1
return items
mov135_episodes_str_default_id = '1'
#mov135_episodes_str1 = ''
#mov135_episodes_str2 = ''
mov135_episodes_str3 = '<li '
mov135_episodes_str4 = 'http://' + mov135_site
mov135_episodes_str5 = 'title="'
mov135_episodes_str6 = '"'
mov135_episodes_str7 = 'href="'
mov135_episodes_str8 = '"'
def mov135_episodes (params):
name = 'mov135_episodes()'
data = json.loads(base64.b64decode(params['data']), 'utf-8')
try:
playlist_id = data['playlist_id']
playlist_title = data['playlist_title']
except:
playlist_id = mov135_episodes_str_default_id
playlist_title = '預設'
html = data['html']
htmlToExplode = html
videos = htmlToExplode.split(mov135_episodes_str3)
videos.pop(0)
siteURLprefix = mov135_episodes_str4
items = []
for video in videos:
title = playlist_title + ': ' + str_between(video, mov135_episodes_str5, mov135_episodes_str6).strip()
link = siteURLprefix + str_between(video, mov135_episodes_str7, mov135_episodes_str8).strip()
# xbmc.log('[%s] %s' % (name, 'link={' + link + '}'), xbmc.LOGNOTICE)
link = build_url_dict({'action': 'mov135_episode', 'link': link})
items.append({'title': title, 'link': link, 'isFolder': False, 'IsPlayable': 'True'})
return items
def mov135_episode (params):
name = 'mov135_episode()'
link_orig = params['link']
xbmc.log('[%s] %s' % (name, 'input: link={' + link_orig + '}'), xbmc.LOGNOTICE)
html = get_link_contents(link_orig)
if ('' == html):
return []
htmlToExplode = str_between(html, 'cms_player =', '</script>')
link = str_between(htmlToExplode, '"url":"', '"')
if ((-1) != link.find('http')):
link = str_between(htmlToExplode, '"url":"', '"').replace('\\/', '/')
else:
xbmc.log('[%s] %s' % (name, 'reading: link={' + link + '}'), xbmc.LOGNOTICE)
link = 'http://play.135mov.com/Aliplayer/Aliplayer-ld.php?videourl=' + link
html = get_link_contents(link)
if ('' == html):
return []
htmlToExplode = str_between(html, 'player =', '</script>')
link = str_between(htmlToExplode, '"source": "', '"')
xbmc.log('[%s] %s' % (name, 'playing: link={' + link + '}'), xbmc.LOGNOTICE)
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)
# -- 135mov.com --
# -- kubo --
kubo_episodes_URL_prefix = 'http://www.99kubo.tv'
kubo_episodes_str1 = '<div class="hideCont"'
kubo_episodes_str2 = '</ul>'
kubo_episodes_str3 = '<li>'
kubo_episodes_str4 = '">'
kubo_episodes_str5 = '</a>'
kubo_episodes_str6 = 'href="'
kubo_episodes_str7 = '"'
kubo_episodes_str8 = '<ul id="tabber"'
kubo_episodes_str9 = '</ul>'
kubo_episodes_strA = '<li'
kubo_episodes_strB = '<b>'
kubo_episodes_strC = '</b>'
kubo_episodes_strD = '<ul>'
kubo_episodes_strE = '</ul>'
def kubo_episodes (params):
name = 'kubo_episodes()'
xbmc.log('[%s] %s' % (name, 'link={' + params['link'] + '}'), xbmc.LOGNOTICE)
html = get_link_contents(params['link'])
if ('' == html):
return []
htmlToExplode = str_between(html, kubo_episodes_str8, kubo_episodes_str9)
fmts = htmlToExplode.split(kubo_episodes_strA)
fmts.pop(0)
fmtIndex = 0
for fmt in fmts:
title = str_between(fmt, kubo_episodes_strB, kubo_episodes_strC).strip()
xbmc.log('[%s] %s' % (name, 'fmtIndex={' + str(fmtIndex) + '}' + '; title={' + title + '}'), xbmc.LOGNOTICE)
if ('FLV66' == title):
xbmc.log('[%s] %s' % (name, 'if (\'FLV66\' == title):'), xbmc.LOGNOTICE)
break
fmtIndex += 1
if (fmtIndex >= len(fmts)):
xbmc.log('[%s] %s' % (name, 'if (fmtIndex >= len(fmts)): {' + str(fmtIndex) + '}; {' + str(len(fmts)) + '}'), xbmc.LOGNOTICE)
htmlToExplode = str_between(html, kubo_episodes_str1, kubo_episodes_str2)
fmt_title = '預設'
else:
xbmc.log('[%s] %s' % (name, 'else: {' + str(fmtIndex) + '}; {' + str(len(fmts)) + '}'), xbmc.LOGNOTICE)
fmtHTML = html.split(kubo_episodes_str1)
fmtHTML.pop(0)
htmlToExplode = str_between(fmtHTML[fmtIndex], kubo_episodes_strD, kubo_episodes_strE)
fmt_title = title
videos = htmlToExplode.split(kubo_episodes_str3)
videos.pop(0)
items = []
for video in videos:
title = fmt_title + ': ' + str_between(video, kubo_episodes_str4, kubo_episodes_str5).strip()
link = kubo_episodes_URL_prefix + str_between(video, kubo_episodes_str6, kubo_episodes_str7).strip()
link = build_url_dict({'action': 'kubo_episode', 'link': link})
items.append({'title': title, 'link': link, 'isFolder': False, 'IsPlayable': 'True'})
return items
# -- kubo --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment