Skip to content

Instantly share code, notes, and snippets.

@ypchen
Last active February 9, 2021 13:50
Show Gist options
  • Save ypchen/3312e9f0ee2e9268d849057364c7fa9f to your computer and use it in GitHub Desktop.
Save ypchen/3312e9f0ee2e9268d849057364c7fa9f to your computer and use it in GitHub Desktop.
Auto-update for plugin.video.hdp_ims
def my_gist_hash ():
return '3312e9f0ee2e9268d849057364c7fa9f'
def my_addon_version ():
return '1.18.1'
def my_version ():
return my_addon_version() + '-gist-r11'
# priv: revision 70
# 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')])
sites = [
{
'title': '酷播 99KUBO',
'action': 'list_items',
'callback': 'kubo_id()',
'isFolder': True,
'siteVisible': 'siteVisible = True'
},
{
'title': '劇迷 gimy.tv',
'action': 'list_items',
'callback': 'gimytv_id()',
'isFolder': True,
'siteVisible': 'siteVisible = True'
},
{
'title': '劇迷 gimy.cc',
'action': 'list_items',
'callback': 'gimycc_id()',
'isFolder': True,
'siteVisible': 'siteVisible = True'
},
]
def read_program (python_program):
python_program_text = ''
if os.path.isfile(python_program):
with open(python_program, 'r') as f:
python_program_text = f.read()
return (python_program_text)
def read_site_order ():
python_file = 'site_order.py'
return read_program(os.path.join(get_tempdir(), python_file))
def read_youtube_channels ():
python_file = 'YouTube_Channels.py'
# 1st: try /tmp
python_program_text = read_program(os.path.join(get_tempdir(), python_file))
if (0 >= len(python_program_text)):
# 2nd: try /userdata
python_program_text = read_program(os.path.join(xbmc.translatePath('special://masterprofile'), 'addon_data/plugin.video.hdp_ims', python_file))
return (python_program_text)
def list_sites (params):
name = 'list_sites()'
site_order = []
youtube_channels = []
xbmc.log('[%s] %s' % (name, '0. site_order={' + ', '.join(map(str, site_order)) + '}'), xbmc.LOGNOTICE)
xbmc.log('[%s] %s' % (name, '0. youtube_channels={' + ', '.join(map(str, youtube_channels)) + '}'), xbmc.LOGNOTICE)
# read user-defined site order
exec read_site_order()
# check if site_order is valid
if (len(site_order) != len(sites)):
site_order = range(len(sites))
xbmc.log('[%s] %s' % (name, '1. site_order={' + ', '.join(map(str, site_order)) + '}'), xbmc.LOGNOTICE)
# read user-defined youtube channels
exec read_youtube_channels()
xbmc.log('[%s] %s' % (name, '2. youtube_channels={' + ', '.join(youtube_channels) + '}'), xbmc.LOGNOTICE)
for site_index in site_order:
site = sites[site_index]
exec site['siteVisible']
if (siteVisible):
li = xbmcgui.ListItem(site['title'])
params['action'] = site['action']
params['callback'] = site['callback']
params['data'] = base64.b64encode(json.dumps(site).encode('utf-8'))
url = build_url_dict(params)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=site['isFolder'])
if params['show_hidden_sites']:
# Separator
xbmcplugin.addDirectoryItem(handle=addon_handle, url='', listitem=xbmcgui.ListItem('----------'), isFolder=False)
for site in hidden_sites:
li = xbmcgui.ListItem(site['title'])
params['action'] = site['action']
params['callback'] = site['callback']
params['data'] = base64.b64encode(json.dumps(site).encode('utf-8'))
url = build_url_dict(params)
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=site['isFolder'])
# Separator
xbmcplugin.addDirectoryItem(handle=addon_handle, url='', listitem=xbmcgui.ListItem('=========='), isFolder=False)
# Version
if ((not params['show_hidden_sites']) and ('1' == addon.getSetting('hs_show'))):
params['action'] = 'input_password_to_show_hidden_sites'
url = build_url_dict(params)
isFolder = True
else:
url = ''
isFolder = False
xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=xbmcgui.ListItem('[版本資訊] hdp_ims: ' + my_version()), isFolder=isFolder)
# Separator
xbmcplugin.addDirectoryItem(handle=addon_handle, url='', listitem=xbmcgui.ListItem('=========='), isFolder=False)
xbmcplugin.endOfDirectory(addon_handle)
# -- kubo --
kubo_episode_str3 = 'http'
def kubo_videos (params):
data = json.loads(base64.b64decode(params['data']), 'utf-8')
try:
page = int(data['page'])
except:
page = 1
order = str_between(params['link'], '-order-', ' ').strip()
html = get_link_contents(params['link'].replace('.html', '-p-' + str(page) + '.html' ))
if ('' == html):
return []
pageInfo = str_between(html, '當前:', '頁')
if ('' == pageInfo):
pageInfo = '1/1'
pages = pageInfo.split('/')
htmlToExplode = str_between(html, '<div class="listlf">', '<div class="footer">')
videos = htmlToExplode.split('<li>')
videos.pop(0)
siteURLprefix = 'http://www.99kubo.tv'
items = []
items.append({'title': '第 [COLOR limegreen]' + pages[0] + '[/COLOR] 頁/共 [COLOR limegreen]' + pages[1] + '[/COLOR] 頁 目前排序方式:[COLOR limegreen]' + kubo_order_description[order] + '[/COLOR] (可按此處變更)', 'link': params['link'], 'action': 'list_items', 'callback': 'kubo_order(params)', 'isFolder': True})
if (page > 1):
items.append({'title': '上一頁 (回第' + str(page-1) + '頁)', 'link': params['link'], 'action': 'list_items', 'callback': 'kubo_videos(params)', 'isFolder': True, 'page': (page-1)})
for video in videos:
title = str_between(video, 'title="', '"').strip()
link = siteURLprefix + str_between(video, 'href="', '"').strip()
image = str_between(video, 'data-original="', '"').strip()
updateAt = str_between(video, '<p>更新:', '</p>').strip()
score = str_between(video, '<p>得分:', '</p>').strip()
items.append({'title': '[COLOR goldenrod]' + score + '[/COLOR] ' + title + ' (' + updateAt + ' 更新)', 'link': link, 'action': 'list_items', 'callback': 'kubo_episodes(params)', 'isFolder': True, 'image': image})
if ((-1) != html.find('>下一页&gt;</a>')):
items.append({'title': '下一頁 (到第' + str(page+1) + '頁)', 'link': params['link'], 'action': 'list_items', 'callback': 'kubo_videos(params)', 'isFolder': True, 'page': (page+1)})
return items
# -- kubo --
# -- gimy.tv --
def gimytv_id ():
# hard-coded top level menu items
# link is the -id-- in the search criteria
return [
{
'title': '電視劇', 'link': 'https://gimy.tv/genre/2-----------.html', 'action': 'list_items',
'callback': 'gimytv_drama_category(params)', 'isFolder': True
},
{
'title': '電影', 'link': 'https://gimy.tv/genre/1-----------.html', 'action': 'list_items',
'callback': 'gimytv_movie_category(params)', 'isFolder': True
},
{
'title': '動漫', 'link': 'https://gimy.tv/genre/4-----------.html', 'action': 'list_items',
'callback': 'gimytv_area(params)', 'isFolder': True
},
{
'title': '綜藝', 'link': 'https://gimy.tv/genre/3-----------.html', 'action': 'list_items',
'callback': 'gimytv_area(params)', 'isFolder': True
}
]
gimytv_filter_URL_prefix = 'https://gimy.tv'
gimytv_filter_insert_all = '全部'
gimytv_filter_insert_at = '2020'
gimytv_filter_insert_this = '2021'
gimytv_filter_insert_pre = '-'
gimytv_filter_insert_post = '.'
gimytv_filter_str1 = '</ul>'
gimytv_filter_str2 = '<a '
gimytv_filter_str3 = '>'
gimytv_filter_str4 = '</a'
gimytv_filter_str5 = 'href="'
gimytv_filter_str6 = '"'
def gimytv_filter (params, url, explodeStart, nextCallback):
html = get_link_contents(url)
if ('' == html):
return []
htmlToExplode = str_between(html, explodeStart, gimytv_filter_str1)
videos = htmlToExplode.split(gimytv_filter_str2)
videos.pop(0)
siteURLprefix = gimytv_filter_URL_prefix
items = []
prevTitle = ''
for video in videos:
title = str_between(video, gimytv_filter_str3, gimytv_filter_str4).strip()
# order asc
if ((prevTitle == gimytv_filter_insert_at) and (title == gimytv_filter_insert_all)):
items.append({'title': gimytv_filter_insert_this, 'link': link.replace(gimytv_filter_insert_pre + gimytv_filter_insert_at + gimytv_filter_insert_post, gimytv_filter_insert_pre + gimytv_filter_insert_this + gimytv_filter_insert_post), 'action': 'list_items', 'callback': nextCallback, 'isFolder': True})
link = siteURLprefix + str_between(video, gimytv_filter_str5, gimytv_filter_str6).strip()
# order desc
if ((prevTitle == gimytv_filter_insert_all) and (title == gimytv_filter_insert_at)):
items.append({'title': gimytv_filter_insert_this, 'link': link.replace(gimytv_filter_insert_pre + gimytv_filter_insert_at + gimytv_filter_insert_post, gimytv_filter_insert_pre + gimytv_filter_insert_this + gimytv_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 gimytv_drama_category (params):
return gimytv_filter (params, params['link'], '">类型', 'gimytv_year(params)')
def gimytv_movie_category (params):
return gimytv_filter (params, params['link'], '">类型', 'gimytv_area(params)')
def gimytv_area (params):
return gimytv_filter (params, params['link'], '">地区', 'gimytv_year(params)')
def gimytv_year (params):
return gimytv_filter (params, params['link'], '">年份', 'gimytv_videos(params)')
gimytv_videos_str1 = 'class="myui-page '
gimytv_videos_str2 = '</ul>'
gimytv_videos_str3 = 'class="visible-xs"'
gimytv_videos_str4 = '</li>'
gimytv_videos_str5 = '">'
gimytv_videos_str6 = '/'
gimytv_videos_str7 = '/'
gimytv_videos_str8 = '</a>'
#gimytv_videos_str9 = 'pagegbk" data="p-'
#gimytv_videos_strA = '">尾頁</a>'
gimytv_videos_strB = 'class="myui-vodlist '
gimytv_videos_strC = '<div class="myui-foot '
gimytv_videos_strD = '<li '
gimytv_videos_strE = 'https://gimy.tv'
gimytv_videos_strF = '</li>'
gimytv_videos_strG = '上一页'
gimytv_videos_strH = '">'
gimytv_videos_strI = '</a'
gimytv_videos_strJ = 'href="'
gimytv_videos_strK = '"'
gimytv_videos_strL = 'title="'
gimytv_videos_strM = '"'
gimytv_videos_strN = 'href="'
gimytv_videos_strO = '"'
gimytv_videos_strP = 'data-original="'
gimytv_videos_strQ = '"'
gimytv_videos_strR = 'pic-text text-right">'
gimytv_videos_strS = '</span>'
gimytv_videos_strT = '下一页'
gimytv_videos_strU = '">'
gimytv_videos_strV = '</a'
gimytv_videos_strW = 'href="'
gimytv_videos_strX = '"'
gimytv_videos_strY = 'text-muted hidden-xs">'
gimytv_videos_strZ = '</p>'
def gimytv_videos (params):
name = 'gimytv_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, gimytv_videos_str1, gimytv_videos_str2)
pageHtml = str_between(pageHtmlAll, gimytv_videos_str3, gimytv_videos_str4)
pages = []
pages.append(str_between(pageHtml, gimytv_videos_str5, gimytv_videos_str6))
pages.append(str_between(pageHtml, gimytv_videos_str7, gimytv_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, gimytv_videos_strB, gimytv_videos_strC)
videos = htmlToExplode.split(gimytv_videos_strD)
videos.pop(0)
siteURLprefix = gimytv_videos_strE
items = []
items.append({'title': '第 [COLOR limegreen]' + pages[0] + '[/COLOR] 頁/共 [COLOR limegreen]' + pages[1] + '[/COLOR] 頁', 'link': '', 'action': '', 'callback': '', 'isFolder': False})
pageBlocks = pageHtmlAll.split(gimytv_videos_strF)
if (page > 1):
for pageBlock in pageBlocks:
if (gimytv_videos_strG == str_between(pageBlock, gimytv_videos_strH, gimytv_videos_strI).strip()):
link = siteURLprefix + str_between(pageBlock, gimytv_videos_strJ, gimytv_videos_strK).strip()
items.append({'title': '上一頁 (回第' + str(page-1) + '頁)', 'link': link, 'action': 'list_items', 'callback': 'gimytv_videos(params)', 'isFolder': True, 'page': (page-1)})
break
for video in videos:
title = str_between(video, gimytv_videos_strL, gimytv_videos_strM).strip()
if ('' != title):
link = siteURLprefix + str_between(video, gimytv_videos_strN, gimytv_videos_strO).strip()
image = str_between(video, gimytv_videos_strP, gimytv_videos_strQ).strip()
note = '(' + str_between(video, gimytv_videos_strR, gimytv_videos_strS).strip() + ') ' + str_between(video, gimytv_videos_strY, gimytv_videos_strZ).strip()
items.append({'title': title + ' -- ' + note, 'link': link, 'action': 'list_items', 'callback': 'gimytv_sources(params)', 'isFolder': True, 'image': image})
if (int(page) < int(pages[1])):
for pageBlock in pageBlocks:
if (gimytv_videos_strT == str_between(pageBlock, gimytv_videos_strU, gimytv_videos_strV).strip()):
link = siteURLprefix + str_between(pageBlock, gimytv_videos_strW, gimytv_videos_strX).strip()
items.append({'title': '下一頁 (到第' + str(page+1) + '頁)', 'link': link, 'action': 'list_items', 'callback': 'gimytv_videos(params)', 'isFolder': True, 'page': (page+1)})
break
return items
gimytv_sources_str1 = '播放地址'
gimytv_sources_str2 = '</ul>'
gimytv_sources_str3 = '<li>'
gimytv_sources_str4 = '">'
gimytv_sources_str5 = '</a>'
gimytv_sources_str6 = 'href="#'
gimytv_sources_str7 = '"'
gimytv_sources_str8 = '播放地址'
gimytv_sources_str9 = '剧情简介'
gimytv_sources_strA = 'class="tab-content '
gimytv_sources_strB = '<script '
def gimytv_sources (params):
name = 'gimytv_sources()'
html = get_link_contents(params['link'])
if ('' == html):
return []
htmlToExplode = str_between(html, gimytv_sources_str1, gimytv_sources_str2)
videos = htmlToExplode.split(gimytv_sources_str3)
videos.pop(0)
items = []
items.append({'title': '選擇來源:', 'link': '', 'action': '', 'callback': '', 'isFolder': False})
for video in videos:
title = str_between(video, gimytv_sources_str4, gimytv_sources_str5).strip()
playlist_id = str_between(video, gimytv_sources_str6, gimytv_sources_str7).strip()
# playlist_id = title
items.append({'title': title, 'link': params['link'], 'action': 'list_items', 'callback': 'gimytv_episodes(params)', 'isFolder': True, 'playlist_id': playlist_id, 'playlist_title': title, 'html': str_between(str_between(html, gimytv_sources_str8, gimytv_sources_str9), gimytv_sources_strA, gimytv_sources_strB)})
return items
gimytv_episodes_str_default_id = 'playlist1'
gimytv_episodes_str1 = '<div'
gimytv_episodes_str2 = '</ul>'
gimytv_episodes_str3 = '<li '
gimytv_episodes_str4 = 'https://gimy.tv'
gimytv_episodes_str5 = '.html">'
gimytv_episodes_str6 = '<'
gimytv_episodes_str7 = 'href="'
gimytv_episodes_str8 = '"'
def gimytv_episodes (params):
name = 'gimytv_episodes()'
data = json.loads(base64.b64decode(params['data']), 'utf-8')
try:
playlist_id = data['playlist_id']
playlist_title = data['playlist_title']
except:
playlist_id = gimytv_episodes_str_default_id
playlist_title = '預設'
html = data['html']
htmlToExplode = html
videoSources = htmlToExplode.split(gimytv_episodes_str1)
videoSources.pop(0)
for videoSource in videoSources:
if ((-1) != videoSource.find(playlist_id)):
# xbmc.log('[%s] %s' % (name, 'playlist_id={' + playlist_id + '}'), xbmc.LOGNOTICE)
html = videoSource
htmlToExplode = str_between(html, playlist_id, gimytv_episodes_str2)
videos = htmlToExplode.split(gimytv_episodes_str3)
videos.pop(0)
siteURLprefix = gimytv_episodes_str4
items = []
for video in videos:
title = playlist_title + ': ' + str_between(video, gimytv_episodes_str5, gimytv_episodes_str6).strip()
link = siteURLprefix + str_between(video, gimytv_episodes_str7, gimytv_episodes_str8).strip()
# xbmc.log('[%s] %s' % (name, 'link={' + link + '}'), xbmc.LOGNOTICE)
link = build_url_dict({'action': 'gimytv_episode', 'link': link})
items.append({'title': title, 'link': link, 'isFolder': False, 'IsPlayable': 'True'})
return items
return []
def gimytv_episode (params):
html = get_link_contents(params['link'])
if ('' == html):
return []
htmlToExplode = str_between(html, 'player_data=', '</script>')
link = str_between(htmlToExplode, '"url":"', '"').replace('\\/', '/')
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)
# -- gimy.tv --
# -- gimy.cc --
def gimycc_id ():
# hard-coded top level menu items
# link is the -id-- in the search criteria
return [
{
'title': '電視劇', 'link': 'https://gimy.cc/vodshow/drama---time.html', 'action': 'list_items',
'callback': 'gimycc_drama_category(params)', 'isFolder': True
},
{
'title': '電影', 'link': 'https://gimy.cc/vodshow/1---.html', 'action': 'list_items',
'callback': 'gimycc_movie_category(params)', 'isFolder': True
},
{
'title': '動漫', 'link': 'https://gimy.cc/vodshow/anime---.html', 'action': 'list_items',
'callback': 'gimycc_area(params)', 'isFolder': True
},
{
'title': '綜藝', 'link': 'https://gimy.cc/vodshow/variety---.html', 'action': 'list_items',
'callback': 'gimycc_area(params)', 'isFolder': True
}
]
gimycc_filter_URL_prefix = 'https://gimy.cc'
gimycc_filter_insert_all = '全部'
gimycc_filter_insert_at = '2020'
gimycc_filter_insert_this = '2021'
gimycc_filter_insert_pre = '-'
gimycc_filter_insert_post = '-'
gimycc_filter_str1 = '</ul>'
gimycc_filter_str2 = '<a '
gimycc_filter_str3 = '>'
gimycc_filter_str4 = '</a'
gimycc_filter_str5 = 'href="'
gimycc_filter_str6 = '"'
def gimycc_filter (params, url, explodeStart, nextCallback):
html = get_link_contents(url)
if ('' == html):
return []
htmlToExplode = str_between(html, explodeStart, gimycc_filter_str1)
videos = htmlToExplode.split(gimycc_filter_str2)
videos.pop(0)
siteURLprefix = gimycc_filter_URL_prefix
items = []
prevTitle = ''
for video in videos:
title = str_between(video, gimycc_filter_str3, gimycc_filter_str4).strip()
# order asc
if ((prevTitle == gimycc_filter_insert_at) and (title == gimycc_filter_insert_all)):
items.append({'title': gimycc_filter_insert_this, 'link': link.replace(gimycc_filter_insert_pre + gimycc_filter_insert_at + gimycc_filter_insert_post, gimycc_filter_insert_pre + gimycc_filter_insert_this + gimycc_filter_insert_post), 'action': 'list_items', 'callback': nextCallback, 'isFolder': True})
link = siteURLprefix + str_between(video, gimycc_filter_str5, gimycc_filter_str6).strip()
# order desc
if ((prevTitle == gimycc_filter_insert_all) and (title == gimycc_filter_insert_at)):
items.append({'title': gimycc_filter_insert_this, 'link': link.replace(gimycc_filter_insert_pre + gimycc_filter_insert_at + gimycc_filter_insert_post, gimycc_filter_insert_pre + gimycc_filter_insert_this + gimycc_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 gimycc_drama_category (params):
return gimycc_filter (params, params['link'], '<span class="text-muted">類型', 'gimycc_year(params)')
def gimycc_movie_category (params):
return gimycc_filter (params, params['link'], '<span class="text-muted">類型', 'gimycc_area(params)')
def gimycc_year (params):
return gimycc_filter (params, params['link'], '<span class="text-muted">年份', 'gimycc_videos(params)')
def gimycc_area (params):
return gimycc_filter (params, params['link'], '<span class="text-muted">地區', 'gimycc_year(params)')
gimycc_videos_str1 = '<ul class="stui-page text-center clearfix">'
gimycc_videos_str2 = '</ul>'
#gimycc_videos_str3 = ''
#gimycc_videos_str4 = ''
gimycc_videos_str5 = '<span class="num">'
gimycc_videos_str6 = '</span>'
#gimycc_videos_str7 = '下一頁</a>'
#gimycc_videos_str8 = '</ul>'
#gimycc_videos_str9 = 'pagegbk" data="p-'
#gimycc_videos_strA = '">尾頁</a>'
gimycc_videos_strB = '<ul class="stui-vodlist '
gimycc_videos_strC = '<ul class="stui-page '
gimycc_videos_strD = '<div class="stui-vodlist__box'
gimycc_videos_strE = 'https://gimy.cc'
gimycc_videos_strF = '</li>'
gimycc_videos_strG = '上一頁'
gimycc_videos_strH = '">'
gimycc_videos_strI = '</a'
gimycc_videos_strJ = 'href="'
gimycc_videos_strK = '"'
gimycc_videos_strL = 'title="'
gimycc_videos_strM = '"'
gimycc_videos_strN = 'href="'
gimycc_videos_strO = '"'
gimycc_videos_strP = 'data-original="'
gimycc_videos_strQ = '"'
gimycc_videos_strR = 'pic-text text-right">'
gimycc_videos_strS = '</span>'
gimycc_videos_strT = '下一頁'
gimycc_videos_strU = '">'
gimycc_videos_strV = '</a'
gimycc_videos_strW = 'href="'
gimycc_videos_strX = '"'
gimycc_videos_strY = 'text-muted hidden-xs">'
gimycc_videos_strZ = '</p>'
def gimycc_videos (params):
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 []
# pageHtml = str_between(str_between(html, gimycc_videos_str1, gimycc_videos_str2), gimycc_videos_str3, gimycc_videos_str4)
pageHtml = str_between(html, gimycc_videos_str1, gimycc_videos_str2)
pages = str_between(pageHtml, gimycc_videos_str5, gimycc_videos_str6).split('/')
# pages.append(str_between(pageHtml, gimycc_videos_str5, gimycc_videos_str6))
# pages.append(str_between(str_between(pageHtml, gimycc_videos_str7, gimycc_videos_str8), gimycc_videos_str9, gimycc_videos_strA))
if ('' == pages[1]):
pages[1] = str(page)
htmlToExplode = str_between(html, gimycc_videos_strB, gimycc_videos_strC)
videos = htmlToExplode.split(gimycc_videos_strD)
videos.pop(0)
siteURLprefix = gimycc_videos_strE
items = []
items.append({'title': '第 [COLOR limegreen]' + pages[0] + '[/COLOR] 頁/共 [COLOR limegreen]' + pages[1] + '[/COLOR] 頁', 'link': '', 'action': '', 'callback': '', 'isFolder': False})
pageBlocks = pageHtml.split(gimycc_videos_strF)
if (page > 1):
for pageBlock in pageBlocks:
if (gimycc_videos_strG == str_between(pageBlock, gimycc_videos_strH, gimycc_videos_strI).strip()):
link = siteURLprefix + str_between(pageBlock, gimycc_videos_strJ, gimycc_videos_strK).strip()
items.append({'title': '上一頁 (回第' + str(page-1) + '頁)', 'link': link, 'action': 'list_items', 'callback': 'gimycc_videos(params)', 'isFolder': True, 'page': (page-1)})
break
for video in videos:
title = str_between(video, gimycc_videos_strL, gimycc_videos_strM).strip()
if ('' != title):
link = siteURLprefix + str_between(video, gimycc_videos_strN, gimycc_videos_strO).strip()
image = str_between(video, gimycc_videos_strP, gimycc_videos_strQ).strip()
note = '(' + str_between(video, gimycc_videos_strR, gimycc_videos_strS).strip() + ') ' + str_between(video, gimycc_videos_strY, gimycc_videos_strZ).strip()
items.append({'title': title + ' -- ' + note, 'link': link, 'action': 'list_items', 'callback': 'gimycc_sources(params)', 'isFolder': True, 'image': image})
if (int(page) < int(pages[1])):
for pageBlock in pageBlocks:
if (gimycc_videos_strT == str_between(pageBlock, gimycc_videos_strU, gimycc_videos_strV).strip()):
link = siteURLprefix + str_between(pageBlock, gimycc_videos_strW, gimycc_videos_strX).strip()
items.append({'title': '下一頁 (到第' + str(page+1) + '頁)', 'link': link, 'action': 'list_items', 'callback': 'gimycc_videos(params)', 'isFolder': True, 'page': (page+1)})
break
return items
def gimycc_sources (params):
html = get_link_contents(params['link'])
if ('' == html):
return []
htmlToExplode = str_between(html, '<ul class="nav nav-tabs pull-right', '</ul>')
videos = htmlToExplode.split('<li>')
videos.pop(0)
items = []
items.append({'title': '選擇來源:', 'link': '', 'action': '', 'callback': '', 'isFolder': False})
for video in videos:
title = str_between(video, '">', '</a>').strip()
playlist_id = str_between(video, 'href="#', '"').strip()
items.append({'title': title, 'link': params['link'], 'action': 'list_items', 'callback': 'gimycc_episodes(params)', 'isFolder': True, 'playlist_id': playlist_id, 'html': str_between(html, '<div class="tab-content ', '<div class="stui-pannel-box">')})
return items
def gimycc_episodes (params):
data = json.loads(base64.b64decode(params['data']), 'utf-8')
try:
playlist_id = data['playlist_id']
except:
playlist_id = 'playlist1'
html = data['html']
htmlToExplode = str_between(html, 'id="' + playlist_id + '"', '</ul>')
videos = htmlToExplode.split('<li')
videos.pop(0)
siteURLprefix = 'https://gimy.cc'
items = []
for video in videos:
title = str_between(video, '">', '<').strip()
link = siteURLprefix + str_between(video, 'href="', '"').strip()
link = build_url_dict({'action': 'gimycc_episode', 'link': link})
items.append({'title': title, 'link': link, 'isFolder': False, 'IsPlayable': 'True'})
return items
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'}
def gimycc_episode (params):
html = get_link_contents(params['link'])
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":"', '"')
n = 2
lineSplit = [line[i:i+n] for i in range(0, len(line), n)]
for s in lineSplit:
link = link + gimycc_episode_url_code_dict[s]
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)
# -- gimy.cc --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment