Repository: zhengfan2014/xbmc-kodi-private-china-addons
Branch: py2
Commit: 984856b358da
Files: 176
Total size: 1.3 MB
Directory structure:
gitextract_lwjw29km/
├── .github/
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ ├── ------.md
│ │ ├── -----.md
│ │ ├── ----.md
│ │ └── feature_request.md
│ ├── auto.py
│ └── workflows/
│ └── auto.yml
├── LICENSE
├── README.md
├── addons.xml
├── addons.xml.md5
├── metadata.douban.com.python/
│ ├── LICENSE.txt
│ ├── README.md
│ ├── addon.xml
│ ├── python/
│ │ ├── lib/
│ │ │ ├── __init__.py
│ │ │ └── tmdbscraper/
│ │ │ ├── __init__.py
│ │ │ ├── api_utils.py
│ │ │ ├── fanarttv.py
│ │ │ ├── imdbratings.py
│ │ │ ├── tmdb.py
│ │ │ ├── tmdbapi.py
│ │ │ └── traktratings.py
│ │ ├── scraper.py
│ │ ├── scraper_config.py
│ │ └── scraper_datahelper.py
│ └── resources/
│ ├── language/
│ │ └── Chinese (Simple)/
│ │ └── strings.po
│ └── settings.xml
├── plugin.audio.jsososo/
│ ├── addon.py
│ ├── addon.xml
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ ├── Chinese (Simple)/
│ │ │ └── strings.po
│ │ └── English/
│ │ └── strings.xml
│ ├── lib/
│ │ └── __init__.py
│ └── settings.xml
├── plugin.video.acfun/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.bangumi/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ ├── __init__.py
│ ├── zhcdict.json
│ └── zhconv.py
├── plugin.video.bilibili/
│ ├── addon.py
│ ├── addon.xml
│ ├── danmuku.py
│ ├── readme.md
│ ├── resources/
│ │ ├── __init__.py
│ │ ├── language/
│ │ │ ├── Chinese (Simple)/
│ │ │ │ └── strings.po
│ │ │ ├── English/
│ │ │ │ └── strings.xml
│ │ │ ├── resource.language.en_us/
│ │ │ │ └── strings.po
│ │ │ └── resource.language.zh_cn/
│ │ │ └── strings.po
│ │ ├── lib/
│ │ │ └── __init__.py
│ │ └── settings.xml
│ └── xml2ass.py
├── plugin.video.bimibimi[停止更新]/
│ ├── addon.py
│ ├── addon.xml
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.changku/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.cine/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.clicli[停止更新]/
│ ├── addon.py
│ ├── addon.xml
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.huanxi/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.kaiyan/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.medicalvideo/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.pengpai[停止更新]/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.reallive/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.skypixel/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.taptap/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.vid/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.weibotv/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.xigua[停止更新]/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── plugin.video.xinpianchang/
│ ├── addon.py
│ ├── addon.xml
│ ├── readme.md
│ └── resources/
│ ├── __init__.py
│ ├── language/
│ │ └── English/
│ │ └── strings.xml
│ └── lib/
│ └── __init__.py
├── service.subtitles.acfun/
│ ├── addon.xml
│ ├── readme.md
│ ├── resources/
│ │ └── lib/
│ │ ├── __init__.py
│ │ └── xml2ass.py
│ └── service.py
├── service.subtitles.bilibili/
│ ├── addon.xml
│ ├── readme.md
│ ├── resources/
│ │ └── lib/
│ │ ├── __init__.py
│ │ └── xml2ass.py
│ └── service.py
└── step1/
├── README.MD
├── acfun-rank-list.py
├── acfun-video.py
├── bangumi.py
├── bilibili-all-list.py
├── bilibili-bangumi-list.py
├── bilibili-rank-list.py
├── bilibili-video-api.py
├── bilibili-video-list.py
├── kaiyan.py
├── livideo.py
├── pengpai.py
├── taptap.py
├── weibo.py
├── weibomiaopai的js加密算法破解.py
├── 医学卫视.py
├── 国土公开课.py
└── 新片场和场库.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
custom: ["afdian.net/@zhengfan2014", "paypal.me/nxsoft"]
================================================
FILE: .github/ISSUE_TEMPLATE/------.md
================================================
---
name: "\U0001F308功能要求"
about: 为这个项目提出一个想法
title: ''
labels: ''
assignees: ''
---
**您的功能请求是否与问题有关? 请描述**
清楚简洁地说明问题所在
**描述您想要的解决方案**
对您想要发生的事情的简洁明了的描述
**描述您考虑过的替代方案**
对您考虑过的所有替代解决方案或功能的简洁明了的描述
**其他背景**
在此处添加有关功能请求的其他任何上下文或屏幕截图
================================================
FILE: .github/ISSUE_TEMPLATE/-----.md
================================================
---
name: "❌错误报告"
about: 创建报告以帮助我们改进
title: ''
labels: ''
assignees: ''
---
**描述错误**
清楚简明地描述错误是什么
**重现**
重现行为的步骤:
1. 去 '...'
2. 点击 '....'
3. 划到 '....'
4. 出错
**预期行为**
对您期望发生的事情的简洁明了的描述
**屏幕截图**
如果适用,请添加屏幕截图以帮助解释您的问题
**设备信息**
- 设备: [e.g. 电脑,手机,电视盒子,xbox]
- 系统: [e.g.Win10,MacOS Big Sur]
- Kodi 版本 [e.g. kodi18, kodi17]
**其他**
在此处添加有关该问题的任何其他上下文
================================================
FILE: .github/ISSUE_TEMPLATE/----.md
================================================
---
name: 功能要求
about: 为这个项目提出一个想法
title: ''
labels: ''
assignees: ''
---
**您的功能请求是否与问题有关? 请描述**
清楚简洁地说明问题所在
**描述您想要的解决方案**
对您想要发生的事情的简洁明了的描述
**描述您考虑过的替代方案**
对您考虑过的所有替代解决方案或功能的简洁明了的描述
**其他背景**
在此处添加有关功能请求的其他任何上下文或屏幕截图
================================================
FILE: .github/ISSUE_TEMPLATE/feature_request.md
================================================
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
================================================
FILE: .github/auto.py
================================================
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import re
import xml.etree.cElementTree as et
import zipfile
import shutil
import hashlib
workpath = '/workdir/python2/'
addons_xml = et.Element('addons')
# 匹配所有需要处理的kodi插件
for pluginname in os.listdir(workpath):
if re.search('\[停止更新\]|video.vid|bangumi|cine|reallive', pluginname):
# 跳过停止更新的项目
pass
elif re.search('metadata.*', pluginname) or re.search('plugin.*', pluginname) or re.search('service.*', pluginname):
# 读取xml获取版本
parser = et.parse(workpath + "/" + pluginname + "/addon.xml")
root = parser.getroot()
version = root.attrib['version']
# 创建repo
basepath = workpath + "/repo/" + pluginname + '/'
if not os.path.exists(basepath):
os.makedirs(basepath)
# 压缩
zippath = basepath + str(pluginname) + '-' + version + '.zip'
f = zipfile.ZipFile(zippath, 'w', zipfile.ZIP_DEFLATED)
for dirpath, dirnames, filenames in os.walk(workpath + '/' + pluginname):
# 这一句很重要,不replace的话,就从根目录开始复制
fpath = dirpath.replace(workpath + '/', '')
fpath = fpath and fpath + os.sep or '' # 这句话理解我也点郁闷,实现当前文件夹以及包含的所有文件的压缩
for filename in filenames:
f.write(os.path.join(dirpath, filename), fpath+filename)
print(pluginname + '压缩成功')
f.close()
# 拷贝icon
shutil.copy(workpath + '/' + str(pluginname) + '/icon.png', basepath + 'icon.png')
# 合并xml
addons_xml.append(root)
# 输出addons.xml
tree = et.ElementTree(addons_xml)
tree.write(workpath + '/addons.xml', "UTF-8",xml_declaration=True)
# 生成addons.xml.md5
f = open(workpath + '/addons.xml')
m2 = hashlib.md5()
text = f.read()
m2.update(text)
f.close()
with open(workpath + '/addons.xml.md5','w') as f: # 如果filename不存在会自动创建, 'w'表示写数据,写之前会清空文件中的原有数据!
f.write(m2.hexdigest())
f.close()
================================================
FILE: .github/workflows/auto.yml
================================================
name: kodi 插件自动化
on: push
jobs:
my-job:
runs-on: ubuntu-latest
name: 打包Kodi插件并自动更新插件库
steps:
- name: 初始化环境
run: |
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
sudo apt install python
- name: 克隆代码
working-directory: /workdir
run: |
df -hT $PWD
git clone https://github.com/zhengfan2014/xbmc-kodi-private-china-addons -b py2 python2
- name: 运行python
run: |
python /workdir/python2/.github/auto.py
- name: Commit 文件
run: |
cd /workdir/python2
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add repo
git add addons.xml
git add addons.xml.md5
git commit -m "[bot] 自动打包插件并推送到存储库"
git init
- name: Push 到 Github
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: py2
repository: zhengfan2014/xbmc-kodi-private-china-addons
directory: /workdir/python2
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2020 zhengfan2014
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# zhengfan2014的kodi插件仓库


[![酷安粉丝][coolapk]](http://www.coolapk.com/u/2864549) [![b站粉丝][bilibili]](https://space.bilibili.com/25818910)
[![爱发电本月收入][mon]](https://afdian.net/@zhengfan2014)
[![爱发电发电人数][once]](https://afdian.net/@zhengfan2014)
----
## 介绍
xbmc-kodi-private-china-addons 是一个存放由zhengfan2014编写和维护的Kodi插件的GitHub仓库。可以为Kodi增加播放Bilibili等视频网站和挂载弹幕等奇奇怪怪的功能。目前借助社区的力量慢速发展中,目前已适配数十个网站的音视频内容。
----
## 插件目录
### 视频插件
插件目录 | 插件名 | 版本 | 最后更新 | 简介
:------------------ | :----: | ---- | ---- | ----
plugin.video.bilibili | bilibili | 0.5.8 | 2021-02-18 | bilibili是国内知名的视频弹幕网站,这里有最及时的动漫新番,最棒的ACG氛围,最有创意的Up主。大家可以在这里找到许多欢乐
plugin.video.taptap | Taptap | 0.2.2 | 2021-02-17 | TapTap是一个推荐高品质手游的手游分享社区,实时同步全球各大应用市场游戏排行榜,与全球玩家共同交流并发掘高品质手游。每一款推荐游戏,都是由专业的测评团队从全球海量的游戏中精选而出,只为你提供好玩的手机游戏。
plugin.video.acfun | acfun | 0.2.3 | 2020-09-15 | AcFun是一家弹幕视频网站,致力于为每一个人带来欢乐
plugin.video.changku | 场库 | 0.1.0 | 2020-03-29 | 高品质短片分享平台,汇集优秀视频短片及微电影创作人,实时不断分享全球优秀视频短片,微电影
plugin.video.huanxi | 欢喜首映 | 0.1.0 | 2020-03-29 | 欢喜首映拥有王家卫、徐峥、陈可辛、宁浩、顾长卫、张一白、贾樟柯、张艺谋等巨匠影人为平台定制的大制作网剧、网络大电影,将视频播放与内容制作合二为一,首映厅首发好电影
plugin.video.skypixel | 天空之城 | 0.1.0 | 2020-03-29 | 世界各地的航拍摄影师、拍手叫绝的航拍作品与独具价值的航拍攻略。全世界的探索者们互相启发,乐在其中
plugin.video.xinpianchang | 新片场 | 0.1.0 | 2020-03-29 | 新片场汇聚全球原创优质视频及创作人,提供4K、无广告、无水印视频观看,专业的视频艺术学习教程,正版视觉素材交易等,与数百万创作人一起用作品打动世界
plugin.video.weibotv | 微博视频 | 0.1.1 | 2020-03-16 | 随时随地发现新鲜事!微博带你欣赏世界上每一个精彩瞬间,了解每一个幕后故事。
plugin.video.kaiyan | 开眼 | 0.1.0 | 2020-03-10 | 精选视频推荐,每日大开眼界
----
### 音乐插件
插件目录 | 插件名 | 版本 | 最后更新 | 简介
:------------------ | :----: | ---- | ---- | ----
plugin.audio.jsososo | jsososo | 0.1.0 | 2020-05-15 |music.jsososo.com的音乐插件,播放你自己的网易云和QQ音乐歌单和日推
### 弹幕插件
插件目录 | 插件名 | 版本 | 最后更新 | 简介
:------------------ | :----: | ---- | ---- | ----
service.subtitles.acfun | Acfun 弹幕 | 0.1.1 | 2020-07-19 |获取并挂载acfun任意视频和番剧的弹幕,支持配合acfun插件显示弹幕,也可以用于本地nas上的番剧或者bangumi插件显示弹幕
service.subtitles.bilibili | Bilibili 弹幕 | 0.1.1 | 2020-07-19 |获取并挂载b站任意视频和番剧的弹幕,支持配合b站插件显示弹幕,也可以用于本地nas上的番剧或者bangumi插件显示弹幕
----
### 原创插件
#### 番剧聚合
插件目录 | 插件名 | 版本 | 最后更新 | 简介
:------------------ | :----: | ---- | ---- | ----
plugin.video.bangumi | bangumi | 0.2.1 | 2021-02-18 |模块化的小众番剧网站聚合插件,提供开发文档,让有python基础的用户无需学习kodi插件开发知识,为本插件快速适配番剧网站
----
#### 电影聚合
插件目录 | 插件名 | 版本 | 最后更新 | 简介
:------------------ | :----: | ---- | ---- | ----
plugin.video.cine | cine | 0.2.0 | 2020-06-14 |模块化的小众电影/电视剧/综艺网站聚合插件,提供开发文档,让有python基础的用户无需学习kodi插件开发知识,为本插件快速适配电影网站
----
#### 新闻/自媒体聚合
插件目录 | 插件名 | 版本 | 最后更新 | 简介
:------------------ | :----: | ---- | ---- | ----
plugin.video.vid | vid | 0.1.0 | 2020-05-03 |模块化的新闻/自媒体等单一视频网站聚合插件,提供开发文档,让有python基础的用户无需学习kodi插件开发知识,为本插件快速适配新闻/自媒体等网站
----
#### 直播聚合
插件目录 | 插件名 | 版本 | 最后更新 | 简介
:------------------ | :----: | ---- | ---- | ----
plugin.video.reallive | reallive | 0.1.1 | 2020-06-09 |模块化的直播网站聚合插件,让有python基础的用户无需学习kodi插件开发知识,为本插件快速适配各大直播网站
## 插件库(New)
Github:
Gitee:
## 下载&更新地址
### Github Action全自动打包(New)
国内 - Gitee:
https://gitee.com/zhengfan2014/xbmc-kodi-private-china-addons/tree/master/latest
国外 - Github:
https://github.com/zhengfan2014/xbmc-kodi-private-china-addons/tree/master/latest
### 手动打包
国内 - 爱发电
https://afdian.net/@zhengfan2014
国外 - GitHub
推荐,更新比较及时
博客地址:https://zhengfan2014.github.io/
国内 - Gitee
推荐,目前采用github action,两个博客内容会自动同步
博客地址:https://zhengfan2014.gitee.io/
## 捐赠作者
如果您觉得这些小作品对您有很大帮助的话,不妨给作品点一个小小的star,请作者喝一杯咖啡,您的支持也是作者维护插件库的动力
爱发电:https://afdian.net/@zhengfan2014
paypal:http://paypal.me/nxsoft
[coolapk]:https://img.shields.io/badge/dynamic/json?labelColor=11ab60&color=282c34&label=%E9%85%B7%E5%AE%89%20紫碧君&suffix=%20粉丝&query=%24.data.totalSubs&url=https%3A%2F%2Fapi.spencerwoo.com%2Fsubstats%2F%3Fsource%3Dcoolapk%26queryKey%3D2864549&logo=data:image/svg+xml;base64,PHN2ZyBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iNjQiIGhlaWdodD0iNjQiPjxkZWZzPjxzdHlsZS8+PC9kZWZzPjxwYXRoIGQ9Ik0xMjcuODkzIDQyNi42NjdjMjkuOTItNjYuOTg3IDk0LjUwNy0xMTYuNjk0IDE2Ni40LTEzMC4zNDcgNTUuNzg3LTkuNiAxMTIuOTYgNS4wNjcgMTYxLjkyIDMxLjk0N0M0OTcuNzYgMzQ5LjQ0IDUzNC40IDM3OC44OCA1NjcuOTQ3IDQxMS4wNGMtMTYuMTYgMTguNC0zOS4wOTQgMjguODUzLTU3LjQ5NCA0NC43NDctNDYuMTMzLTM4Ljg4LTk2LjY0LTc3LjcwNy0xNTcuOTczLTg3LjA5NC03OC45MzMtMTMuMTczLTE1OC41NiA0OS4yMjctMTcwLjUwNyAxMjcuMTQ3LTguNjkzIDQ1LjkyIDEwLjEzNCA5NC42NjcgNDUuMTc0IDEyNC45MDcgMzkuNjggMzQuOTg2IDk3LjIyNiA0NC41ODYgMTQ3LjYyNiAzMS4yNTMgNTcuNi0xMy45MiAxMDEuOTc0LTU3LjA2NyAxMzYuODU0LTEwMi43NzMgNTQuMDgtNzIuMTA3IDk5LjItMTUwLjQgMTQ3Ljg0LTIyNi4xMzQgMTMuOTItMTkuMTQ2IDQ3LjQxMy0xNy4yMjYgNTguNzIgMy44NCA2My42MjYgMTA5LjAxNCAxMjYuMDggMjE4LjcyIDE4OS42IDMyNy43ODcgNy41NzMgMTUuMDkzIDQuNDI2IDM1Ljc4Ny05LjYgNDYuMTMzLTEzLjA2NyAxMC42MTQtMzMuMzM0IDEwLjI0LTQ2LjEzNC0uNjkzYTk3MDY2LjU1OCA5NzA2Ni41NTggMCAwMS0yMjYuMTg2LTE2Mi43MmMxOC44OC0xNS4wNCAzOC40LTI5LjMzMyA1Ny45NzMtNDMuNDY3IDIzLjczMyAxMi45MDcgNDMuNzg3IDMzLjE3NCA2OS42IDQxLjY1NC0yMC4zNzMtMzkuNTc0LTQzLjYyNy03Ny43MDctNjYuMzQ3LTExNS45NDctNDIuNjY2IDU5LjE0Ny03Ny4wNjYgMTI0LjIxMy0xMjMuMTQ2IDE4MS4wNjdDNTE2IDY2My40NjcgNDQ4LjggNzE2Ljk2IDM2OC42NCA3MjguNDhjLTM4Ljg4IDMuNDEzLTc5LjMwNyA0LjIxMy0xMTYuMzczLTkuOTczLTUzLjQ5NC0xOS4xNDctMTAwLjMyLTU4LjcyLTEyNC41ODctMTEwLjU2LTI4LjIxMy01Ni4xMDctMjYuNzczLTEyNS4wMTQuMjEzLTE4MS4yOHoiIGZpbGw9IiNmZmYiLz48L3N2Zz4=&longCache=true
[bilibili]:https://img.shields.io/badge/dynamic/json?labelColor=FE7398&label=bilibili%20紫碧君&suffix=%20粉丝&query=%24.data.totalSubs&url=https%3A%2F%2Fapi.spencerwoo.com%2Fsubstats%2F%3Fsource%3Dbilibili%26queryKey%3D25818910&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAD7ElEQVR4nO2dW9WrMBCFK6ESkFAJSKiESqgEHCABCZWAhEpAAhL2ecik5dDc/pXLBDLfWnlqy0xmJ5BMQnq5CIIgCIIgCIIgCIIgCEIBAHQAemYfrgCunD6wAKAHsEKxALgx+bCQD8/S9tmgVqeDr1lLigDgZvDhXso+K9TyTBQRwRJ8AHjntl0Flh5QRAQK/mKxPeayWx2OXpBNBKiHvi34b7T2MC4pAvW6twR/RwkRKPizBN8CgEcuESj4Lwm+BwBjahEk+H8EwJRKhOaCDzW8e1JLfkUUH1NgmR3XmHffHR1l+72BSs8d7w8U+JDAnZERQMcV+CtUi7dNqFqibB4J7vtrq7xKCuAasbTMXCL4T+5aVk6+2xHUrWdhruAR6HIJcOeu2UHI8zyAe2ytWfEdWz9PVvQ8YAmIQ5dDAB9LFsMVAv8oMO2zAGrC5WNIarRiAuKR9jYEd9pY08aa6uUzIHGRdkgKd8pY0yc1WjEBAqypDYoAG0QAZkQAZkQAZkQAZk4vANQenjsSzS3I/wcSbXU5jQBUkRtdf4Rar90v8kSv3+I3ffCCSpk8I/w+lgDkdI/v2rEp2CaiWm1AsDQLlDAD+dlFXLMeAaCSeLZdaSFE5VUQNot38cKuEeBgAsSuG0flVZBmEanbXfNQAsS0fgBYIn2fIu3/BBMHEyBmDXlFfA8IzeHb+Ems4WAChKykrVA9ZfsQTL57jXzRg4A5wC/A8N4ADiZAZwm2XjW75Qh2KOTfA0p4kygPw28OJcCVgn3nDnYo2EwEYRgGH0qAMyICMCMCMCMCMCMCMCMCMCMCfP3qwHDOQ4AAUekTk8FaBRihJnZdYbvtCGC7LvmkM63GjVDINPFrQgCq5ETXfmMzI90FXzPvfqt7x4rEu/ZaEcCUxFvgz2zO+BUn6UkoaEEAsptiMSX5e8FoRYCN7cVgb4Vq7U/H50Pq4JNP7Qiw8UFnJwcK+tXy+Wj6PLEvPgHSHv5UgwA1IQIwwyFAyLJin9RoxYgAzAQIkPwNmf26busC+OIx5TDqo5nDT+F/SS/9CYzwb+No49zNy2evkYv0LywGGAXUvp6eSneycqOic0w20k7CNgKE7jJunSGLACTCxF27ylmQc98T5MQUH49swd+I0HPXslLKnT0N+wnkrTKi9JZL/L9i1SorMmdeQ4TQQ7OFMxIMzGD45w8nUL1im7efENZLJpgPSw0pfz0cdt4U3230Td/Tvx2R6d2FrHhEWLkq5PELOMsRPHCPnAZGv1xJteL7jbJiaW3sB2nDvPC/osSYvjRQz4cJ6n7KO3rYQL7M+L6nVtfDVRAEQRAEQRAEQRAEIZ5/SAXmdfXaoQsAAAAASUVORK5CYII=&color=282c34&longCache=true
[mon]:https://img.shields.io/badge/dynamic/json?label=本月收入&query=%24.data.totalSubs&url=https%3A%2F%2Fapi.spencerwoo.com%2Fsubstats%2F%3Fsource%3DafdianIncome%26queryKey%3Dzhengfan2014&prefix=%EF%BF%A5%20&suffix=%20%E6%AF%8F%E6%9C%88&labelColor=946ce6&color=282c34&longCache=true
[once]:https://img.shields.io/badge/dynamic/json?label=%E7%88%B1%E5%8F%91%E7%94%B5&query=%24.data.totalSubs&url=https%3A%2F%2Fapi.spencerwoo.com%2Fsubstats%2F%3Fsource%3DafdianFans%26queryKey%3Dzhengfan2014&suffix=%20%E5%8F%91%E7%94%B5%E4%BA%BA%E6%AC%A1%20%2F%20%E6%9C%88&labelColor=946ce6&color=282c34&longCache=true
================================================
FILE: addons.xml
================================================
豆瓣刮削器Python豆瓣电影提供最新的电影介绍及评论包括上映影片的影讯查询及购票服务。你可以记录想看、在看和看过的电影电视剧,顺便打分、写影评。根据你的口味,豆瓣电影会推荐好电影给你。allicon.pngvideoallAcFun是一家弹幕视频网站,致力于为每一个人带来欢乐。videoall随时随地发现新鲜事!微博带你欣赏世界上每一个精彩瞬间,了解每一个幕后故事。videoall医学微视是配合卫健委宣传司《全民健康素养促进活动》精神,在中华医学会科学普及分会指导下,由中国医学科学院健康科普中心监制而实施,以“让人们多了解一点医学知识,健康就多一份保障”的宗旨,团队只想把医学微视做得更好,让更多的患者能共享到医学专家们多年积累的宝贵经验和知识,能对需要的人有一点点帮助icon.pngfanart.png首个版本Acfun 弹幕插件从 Acfun 下载弹幕icon.pnglogo.pngresources/media/fanart.jpgresources/media/screenshot_1.pngresources/media/screenshot_2.pngresources/media/screenshot_3.pngaudioall网易云音乐,QQ音乐,咪咕音乐聚合插件,API 1000%使用music.jsososo.com的服务icon.pngfanart.png首个版本videoall新片场汇聚全球原创优质视频及创作人,提供4K、无广告、无水印视频观看,专业的视频艺术学习教程,正版视觉素材交易等,与数百万创作人一起用作品打动世界icon.pngfanart.png首个版本videoallTapTap是一个推荐高品质手游的手游分享社区,实时同步全球各大应用市场游戏排行榜,与全球玩家共同交流并发掘高品质手游。每一款推荐游戏,都是由专业的测评团队从全球海量的游戏中精选而出,只为你提供好玩的手机游戏。icon.pngfanart.png首个版本videoall精选视频推荐,每日大开眼界videoall欢喜首映拥有王家卫、徐峥、陈可辛、宁浩、顾长卫、张一白、贾樟柯、张艺谋等巨匠影人为平台定制的大制作网剧、网络大电影,将视频播放与内容制作合二为一,首映厅首发好电影icon.pngfanart.png首个版本videoall高品质短片分享平台,汇集优秀视频短片及微电影创作人,实时不断分享全球优秀视频短片,微电影icon.pngfanart.png首个版本videoallbilibili是国内知名的视频弹幕网站,这里有最及时的动漫新番,最棒的ACG氛围,最有创意的Up主。大家可以在这里找到许多欢乐哔哩哔哩 弹幕插件从 哔哩哔哩 下载弹幕icon.pnglogo.pngresources/media/fanart.jpgresources/media/screenshot_1.pngresources/media/screenshot_2.pngresources/media/screenshot_3.pngvideoall世界各地的航拍摄影师、拍手叫绝的航拍作品与独具价值的航拍攻略。全世界的探索者们互相启发,乐在其中icon.pngfanart.png首个版本
================================================
FILE: addons.xml.md5
================================================
4e63ef3b358c798d9253b01d3d5f5c1c
================================================
FILE: metadata.douban.com.python/LICENSE.txt
================================================
Valid-License-Identifier: GPL-2.0-or-later
SPDX-URL:https://spdx.org/licenses/GPL-2.0-or-later.html
Usage-Guide:
To use the GNU General Public License v2.0 or later put the following SPDX
tag/value pair into a comment according to the placement guidelines in
the licensing rules documentation:
SPDX-License-Identifier: GPL-2.0-or-later
License-Text:
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 , USA
Everyone is permitted to copy and distribute verbatim copies of this license
document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your freedom to share
and change it. By contrast, the GNU General Public License is intended to
guarantee your freedom to share and change free software--to make sure the
software is free for all its users. This General Public License applies to
most of the Free Software Foundation's software and to any other program whose
authors commit to using it. (Some other Free Software Foundation software
is covered by the GNU Lesser General Public License instead.) You can apply
it to your programs, too.
When we speak of free software, we are referring to freedom, not price. Our
General Public Licenses are designed to make sure that you have the freedom
to distribute copies of free software (and charge for this service if you
wish), that you receive source code or can get it if you want it, that you
can change the software or use pieces of it in new free programs; and that
you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to
deny you these rights or to ask you to surrender the rights. These restrictions
translate to certain responsibilities for you if you distribute copies of
the software, or if you modify it.
For example, if you distribute copies of such a program, whether gratis or
for a fee, you must give the recipients all the rights that you have. You
must make sure that they, too, receive or can get the source code. And you
must show them these terms so they know their rights.
We protect your rights with two steps: (1) copyright the software, and (2)
offer you this license which gives you legal permission to copy, distribute
and/or modify the software.
Also, for each author's protection and ours, we want to make certain that
everyone understands that there is no warranty for this free software. If
the software is modified by someone else and passed on, we want its recipients
to know that what they have is not the original, so that any problems introduced
by others will not reflect on the original authors' reputations.
Finally, any free program is threatened constantly by software patents. We
wish to avoid the danger that redistributors of a free program will individually
obtain patent licenses, in effect making the program proprietary. To prevent
this, we have made it clear that any patent must be licensed for everyone's
free use or not licensed at all.
The precise terms and conditions for copying, distribution and modification
follow.
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains a notice
placed by the copyright holder saying it may be distributed under the terms
of this General Public License. The "Program", below, refers to any such program
or work, and a "work based on the Program" means either the Program or any
derivative work under copyright law: that is to say, a work containing the
Program or a portion of it, either verbatim or with modifications and/or translated
into another language. (Hereinafter, translation is included without limitation
in the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not covered
by this License; they are outside its scope. The act of running the Program
is not restricted, and the output from the Program is covered only if its
contents constitute a work based on the Program (independent of having been
made by running the Program). Whether that is true depends on what the Program
does.
1. You may copy and distribute verbatim copies of the Program's source code
as you receive it, in any medium, provided that you conspicuously and appropriately
publish on each copy an appropriate copyright notice and disclaimer of warranty;
keep intact all the notices that refer to this License and to the absence
of any warranty; and give any other recipients of the Program a copy of this
License along with the Program.
You may charge a fee for the physical act of transferring a copy, and you
may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion of it,
thus forming a work based on the Program, and copy and distribute such modifications
or work under the terms of Section 1 above, provided that you also meet all
of these conditions:
a) You must cause the modified files to carry prominent notices stating that
you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in whole or
in part contains or is derived from the Program or any part thereof, to be
licensed as a whole at no charge to all third parties under the terms of this
License.
c) If the modified program normally reads commands interactively when run,
you must cause it, when started running for such interactive use in the most
ordinary way, to print or display an announcement including an appropriate
copyright notice and a notice that there is no warranty (or else, saying that
you provide a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this License.
(Exception: if the Program itself is interactive but does not normally print
such an announcement, your work based on the Program is not required to print
an announcement.)
These requirements apply to the modified work as a whole. If identifiable
sections of that work are not derived from the Program, and can be reasonably
considered independent and separate works in themselves, then this License,
and its terms, do not apply to those sections when you distribute them as
separate works. But when you distribute the same sections as part of a whole
which is a work based on the Program, the distribution of the whole must be
on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest your
rights to work written entirely by you; rather, the intent is to exercise
the right to control the distribution of derivative or collective works based
on the Program.
In addition, mere aggregation of another work not based on the Program with
the Program (or with a work based on the Program) on a volume of a storage
or distribution medium does not bring the other work under the scope of this
License.
3. You may copy and distribute the Program (or a work based on it, under Section
2) in object code or executable form under the terms of Sections 1 and 2 above
provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable source code,
which must be distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three years, to give
any third party, for a charge no more than your cost of physically performing
source distribution, a complete machine-readable copy of the corresponding
source code, to be distributed under the terms of Sections 1 and 2 above on
a medium customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer to distribute
corresponding source code. (This alternative is allowed only for noncommercial
distribution and only if you received the program in object code or executable
form with such an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for making
modifications to it. For an executable work, complete source code means all
the source code for all modules it contains, plus any associated interface
definition files, plus the scripts used to control compilation and installation
of the executable. However, as a special exception, the source code distributed
need not include anything that is normally distributed (in either source or
binary form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component itself
accompanies the executable.
If distribution of executable or object code is made by offering access to
copy from a designated place, then offering equivalent access to copy the
source code from the same place counts as distribution of the source code,
even though third parties are not compelled to copy the source along with
the object code.
4. You may not copy, modify, sublicense, or distribute the Program except
as expressly provided under this License. Any attempt otherwise to copy, modify,
sublicense or distribute the Program is void, and will automatically terminate
your rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses terminated
so long as such parties remain in full compliance.
5. You are not required to accept this License, since you have not signed
it. However, nothing else grants you permission to modify or distribute the
Program or its derivative works. These actions are prohibited by law if you
do not accept this License. Therefore, by modifying or distributing the Program
(or any work based on the Program), you indicate your acceptance of this License
to do so, and all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the Program),
the recipient automatically receives a license from the original licensor
to copy, distribute or modify the Program subject to these terms and conditions.
You may not impose any further restrictions on the recipients' exercise of
the rights granted herein. You are not responsible for enforcing compliance
by third parties to this License.
7. If, as a consequence of a court judgment or allegation of patent infringement
or for any other reason (not limited to patent issues), conditions are imposed
on you (whether by court order, agreement or otherwise) that contradict the
conditions of this License, they do not excuse you from the conditions of
this License. If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations, then as
a consequence you may not distribute the Program at all. For example, if a
patent license would not permit royalty-free redistribution of the Program
by all those who receive copies directly or indirectly through you, then the
only way you could satisfy both it and this License would be to refrain entirely
from distribution of the Program.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply and
the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any patents
or other property right claims or to contest validity of any such claims;
this section has the sole purpose of protecting the integrity of the free
software distribution system, which is implemented by public license practices.
Many people have made generous contributions to the wide range of software
distributed through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing to
distribute software through any other system and a licensee cannot impose
that choice.
This section is intended to make thoroughly clear what is believed to be a
consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in certain
countries either by patents or by copyrighted interfaces, the original copyright
holder who places the Program under this License may add an explicit geographical
distribution limitation excluding those countries, so that distribution is
permitted only in or among countries not thus excluded. In such case, this
License incorporates the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions of
the General Public License from time to time. Such new versions will be similar
in spirit to the present version, but may differ in detail to address new
problems or concerns.
Each version is given a distinguishing version number. If the Program specifies
a version number of this License which applies to it and "any later version",
you have the option of following the terms and conditions either of that version
or of any later version published by the Free Software Foundation. If the
Program does not specify a version number of this License, you may choose
any version ever published by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free programs
whose distribution conditions are different, write to the author to ask for
permission. For software which is copyrighted by the Free Software Foundation,
write to the Free Software Foundation; we sometimes make exceptions for this.
Our decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing and reuse
of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE
OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES
OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest possible
use to the public, the best way to achieve this is to make it free software
which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach
them to the start of each source file to most effectively convey the exclusion
of warranty; and each file should have at least the "copyright" line and a
pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301 , USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this when
it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author Gnomovision comes
with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software,
and you are welcome to redistribute it under certain conditions; type `show
c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may be
called something other than `show w' and `show c'; they could even be mouse-clicks
or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your school,
if any, to sign a "copyright disclaimer" for the program, if necessary. Here
is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision'
(which makes passes at compilers) written by James Hacker.
< signature of Ty Coon > , 1 April 1989 Ty Coon, President of Vice This General
Public License does not permit incorporating your program into proprietary
programs. If your program is a subroutine library, you may consider it more
useful to permit linking proprietary applications with the library. If this
is what you want to do, use the GNU Lesser General Public License instead
of this License.
================================================
FILE: metadata.douban.com.python/README.md
================================================
## The Movie Database Python scraper for Kodi
This is early work on a Python movie scraper for Kodi.
### Manual search by IMDB / TMDB ID
When manually searching you can enter an IMDB or TMDB ID to pull up an exact movie result.
To search by TMDB enter "tmdb/" then the ID, like "tmdb/11". To search by IMDB ID enter it directly.
## Development info
### How to run unit tests
`python -m unittest discover -v` from the main **metadata.themoviedb.org.python** directory.
Python 3 only.
================================================
FILE: metadata.douban.com.python/addon.xml
================================================
豆瓣刮削器Python豆瓣电影提供最新的电影介绍及评论包括上映影片的影讯查询及购票服务。你可以记录想看、在看和看过的电影电视剧,顺便打分、写影评。根据你的口味,豆瓣电影会推荐好电影给你。allicon.png
================================================
FILE: metadata.douban.com.python/python/lib/__init__.py
================================================
================================================
FILE: metadata.douban.com.python/python/lib/tmdbscraper/__init__.py
================================================
def get_imdb_id(uniqueids):
imdb_id = uniqueids.get('imdb')
if not imdb_id or not imdb_id.startswith('tt'):
return None
return imdb_id
# example format for scraper results
_ScraperResults = {
'info',
'ratings',
'uniqueids',
'cast',
'available_art',
'error',
'warning' # not handled
}
================================================
FILE: metadata.douban.com.python/python/lib/tmdbscraper/api_utils.py
================================================
# coding: utf-8
#
# Copyright (C) 2020, Team Kodi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
"""Functions to interact with various web site APIs."""
from __future__ import absolute_import, unicode_literals
import json, xbmc
# from pprint import pformat
try: #PY2 / PY3
from urllib2 import Request, urlopen
from urllib2 import URLError
from urllib import urlencode
except ImportError:
from urllib.request import Request, urlopen
from urllib.error import URLError
from urllib.parse import urlencode
try:
from typing import Text, Optional, Union, List, Dict, Any # pylint: disable=unused-import
InfoType = Dict[Text, Any] # pylint: disable=invalid-name
except ImportError:
pass
HEADERS = {}
def set_headers(headers):
HEADERS.update(headers)
def load_info(url, params=None, default=None, resp_type = 'json'):
# type: (Text, Optional[Dict[Text, Union[Text, List[Text]]]]) -> Union[dict, list]
"""
Load info from external api
:param url: API endpoint URL
:param params: URL query params
:default: object to return if there is an error
:resp_type: what to return to the calling function
:return: API response or default on error
"""
theerror = ''
if params:
url = url + '?' + urlencode(params)
xbmc.log('Calling URL "{}"'.format(url), xbmc.LOGDEBUG)
req = Request(url, headers=HEADERS)
try:
response = urlopen(req)
except URLError as e:
if hasattr(e, 'reason'):
theerror = {'error': 'failed to reach the remote site\nReason: {}'.format(e.reason)}
elif hasattr(e, 'code'):
theerror = {'error': 'remote site unable to fulfill the request\nError code: {}'.format(e.code)}
if default is not None:
return default
else:
return theerror
if resp_type.lower() == 'json':
resp = json.loads(response.read().decode('utf-8'))
else:
resp = response.read().decode('utf-8')
# xbmc.log('the api response:\n{}'.format(pformat(resp)), xbmc.LOGDEBUG)
return resp
================================================
FILE: metadata.douban.com.python/python/lib/tmdbscraper/fanarttv.py
================================================
from . import api_utils
try:
from urllib import quote
except ImportError: # py2 / py3
from urllib.parse import quote
API_KEY = '384afe262ee0962545a752ff340e3ce4'
API_URL = 'https://webservice.fanart.tv/v3/movies/{}'
ARTMAP = {
'movielogo': 'clearlogo',
'hdmovielogo': 'clearlogo',
'hdmovieclearart': 'clearart',
'movieart': 'clearart',
'moviedisc': 'discart',
'moviebanner': 'banner',
'moviethumb': 'landscape',
'moviebackground': 'fanart',
'movieposter': 'poster'
}
def get_details(uniqueids, clientkey, language, set_tmdbid):
media_id = _get_mediaid(uniqueids)
if not media_id:
return {}
movie_data = _get_data(media_id, clientkey)
movieset_data = _get_data(set_tmdbid, clientkey)
if not movie_data and not movieset_data:
return {}
movie_art = {}
movieset_art = {}
if movie_data:
movie_art = _parse_data(movie_data, language)
if movieset_data:
movieset_art = _parse_data(movieset_data, language)
movieset_art = {'set.' + key: value for key, value in movieset_art.items()}
available_art = movie_art
available_art.update(movieset_art)
return {'available_art': available_art}
def _get_mediaid(uniqueids):
for source in ('tmdb', 'imdb', 'unknown'):
if source in uniqueids:
return uniqueids[source]
def _get_data(media_id, clientkey):
headers = {'api-key': API_KEY}
if clientkey:
headers['client-key'] = clientkey
api_utils.set_headers(headers)
fanarttv_url = API_URL.format(media_id)
return api_utils.load_info(fanarttv_url, default={})
def _parse_data(data, language):
result = {}
for arttype, artlist in data.items():
if arttype not in ARTMAP:
continue
for image in artlist:
image_lang = _get_imagelanguage(arttype, image)
if image_lang and image_lang != language:
continue
generaltype = ARTMAP[arttype]
if generaltype == 'poster' and not image_lang:
generaltype = 'keyart'
if artlist and generaltype not in result:
result[generaltype] = []
url = quote(image['url'], safe="%/:=&?~#+!$,;'@()*[]")
resultimage = {'url': url, 'preview': url.replace('.fanart.tv/fanart/', '.fanart.tv/preview/')}
result[generaltype].append(resultimage)
return result
def _get_imagelanguage(arttype, image):
if 'lang' not in image or arttype == 'moviebackground':
return None
if arttype in ('movielogo', 'hdmovielogo', 'hdmovieclearart', 'movieart', 'moviebanner',
'moviethumb', 'moviedisc'):
return image['lang'] if image['lang'] not in ('', '00') else 'en'
# movieposter may or may not have a title and thus need a language
return image['lang'] if image['lang'] not in ('', '00') else None
================================================
FILE: metadata.douban.com.python/python/lib/tmdbscraper/imdbratings.py
================================================
# -*- coding: UTF-8 -*-
#
# Copyright (C) 2020, Team Kodi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
#
# IMDb ratings based on code in metadata.themoviedb.org.python by Team Kodi
# pylint: disable=missing-docstring
import re
from . import api_utils
from . import get_imdb_id
IMDB_RATINGS_URL = 'https://www.imdb.com/title/{}/'
IMDB_RATING_REGEX = re.compile(r'itemprop="ratingValue".*?>.*?([\d.]+).*?<')
IMDB_VOTES_REGEX = re.compile(r'itemprop="ratingCount".*?>.*?([\d,]+).*?<')
IMDB_TOP250_REGEX = re.compile(r'Top Rated Movies #(\d+)')
def get_details(uniqueids):
imdb_id = get_imdb_id(uniqueids)
if not imdb_id:
return {}
votes, rating, top250 = _get_ratinginfo(imdb_id)
return _assemble_imdb_result(votes, rating, top250)
def _get_ratinginfo(imdb_id):
response = api_utils.load_info(IMDB_RATINGS_URL.format(imdb_id), default = '', resp_type='text')
return _parse_imdb_result(response)
def _assemble_imdb_result(votes, rating, top250):
result = {}
if top250:
result['info'] = {'top250': top250}
if votes and rating:
result['ratings'] = {'imdb': {'votes': votes, 'rating': rating}}
return result
def _parse_imdb_result(input_html):
rating = _parse_imdb_rating(input_html)
votes = _parse_imdb_votes(input_html)
top250 = _parse_imdb_top250(input_html)
return votes, rating, top250
def _parse_imdb_rating(input_html):
match = re.search(IMDB_RATING_REGEX, input_html)
if (match):
return float(match.group(1))
return None
def _parse_imdb_votes(input_html):
match = re.search(IMDB_VOTES_REGEX, input_html)
if (match):
return int(match.group(1).replace(',', ''))
return None
def _parse_imdb_top250(input_html):
match = re.search(IMDB_TOP250_REGEX, input_html)
if (match):
return int(match.group(1))
return None
================================================
FILE: metadata.douban.com.python/python/lib/tmdbscraper/tmdb.py
================================================
from datetime import datetime, timedelta
from . import tmdbapi
class TMDBMovieScraper(object):
def __init__(self, url_settings, language, certification_country):
self.url_settings = url_settings
self.language = language
self.certification_country = certification_country
self._urls = None
@property
def urls(self):
if not self._urls:
self._urls = _load_base_urls(self.url_settings)
return self._urls
def search(self, title, year=None):
search_media_id = _parse_media_id(title)
if search_media_id:
if search_media_id['type'] == 'tmdb':
result = _get_movie(search_media_id['id'], self.language, True)
result = [result]
else:
response = tmdbapi.find_movie_by_external_id(search_media_id['id'], language=self.language)
theerror = response.get('error')
if theerror:
return 'error: {}'.format(theerror)
result = response.get('movie_results')
if 'error' in result:
return result
else:
response = tmdbapi.search_movie(query=title, year=year, language=self.language)
theerror = response.get('error')
if theerror:
return 'error: {}'.format(theerror)
result = response['results']
urls = self.urls
def is_best(item):
return item['title'].lower() == title and (
not year or item.get('release_date', '').startswith(year))
if result and not is_best(result[0]):
best_first = next((item for item in result if is_best(item)), None)
if best_first:
result = [best_first] + [item for item in result if item is not best_first]
for item in result:
if item.get('poster_path'):
item['poster_path'] = urls['preview'] + item['poster_path']
if item.get('backdrop_path'):
item['backdrop_path'] = urls['preview'] + item['backdrop_path']
return result
def get_details(self, uniqueids):
media_id = uniqueids.get('tmdb') or uniqueids.get('imdb')
details = self._gather_details(media_id)
if not details:
return None
if details.get('error'):
return details
return self._assemble_details(**details)
def _gather_details(self, media_id):
movie = _get_movie(media_id, self.language)
if not movie or movie.get('error'):
return movie
# don't specify language to get English text for fallback
movie_fallback = _get_movie(media_id)
collection = _get_moviecollection(movie['belongs_to_collection'].get('id'), self.language) if \
movie['belongs_to_collection'] else None
collection_fallback = _get_moviecollection(movie['belongs_to_collection'].get('id')) if \
movie['belongs_to_collection'] else None
return {'movie': movie, 'movie_fallback': movie_fallback, 'collection': collection,
'collection_fallback': collection_fallback}
def _assemble_details(self, movie, movie_fallback, collection, collection_fallback):
info = {
'title': movie['title'],
'originaltitle': movie['original_title'],
'plot': movie.get('overview') or movie_fallback.get('overview'),
'tagline': movie.get('tagline') or movie_fallback.get('tagline'),
'studio': _get_names(movie['production_companies']),
'genre': _get_names(movie['genres']),
'country': _get_names(movie['production_countries']),
'credits': _get_cast_members(movie['casts'], 'crew', 'Writing', ['Screenplay', 'Writer', 'Author']),
'director': _get_cast_members(movie['casts'], 'crew', 'Directing', ['Director']),
'premiered': movie['release_date'],
'tag': _get_names(movie['keywords']['keywords'])
}
if 'countries' in movie['releases']:
certcountry = self.certification_country.upper()
for country in movie['releases']['countries']:
if country['iso_3166_1'] == certcountry and country['certification']:
info['mpaa'] = country['certification']
break
trailer = _parse_trailer(movie.get('trailers', {}), movie_fallback.get('trailers', {}))
if trailer:
info['trailer'] = trailer
if collection:
info['set'] = collection.get('name') or collection_fallback.get('name')
info['setoverview'] = collection.get('overview') or collection_fallback.get('overview')
if movie.get('runtime'):
info['duration'] = movie['runtime'] * 60
ratings = {'themoviedb': {'rating': float(movie['vote_average']), 'votes': int(movie['vote_count'])}}
uniqueids = {'tmdb': movie['id'], 'imdb': movie['imdb_id']}
cast = [{
'name': actor['name'],
'role': actor['character'],
'thumbnail': self.urls['original'] + actor['profile_path']
if actor['profile_path'] else "",
'order': actor['order']
}
for actor in movie['casts'].get('cast', [])
]
available_art = _parse_artwork(movie, collection, self.urls, self.language)
_info = {'set_tmdbid': movie['belongs_to_collection'].get('id')
if movie['belongs_to_collection'] else None}
return {'info': info, 'ratings': ratings, 'uniqueids': uniqueids, 'cast': cast,
'available_art': available_art, '_info': _info}
def _parse_media_id(title):
if title.startswith('tt') and title[2:].isdigit():
return {'type': 'imdb', 'id':title} # IMDB ID works alone because it is clear
title = title.lower()
if title.startswith('tmdb/') and title[5:].isdigit(): # TMDB ID
return {'type': 'tmdb', 'id':title[5:]}
elif title.startswith('imdb/tt') and title[7:].isdigit(): # IMDB ID with prefix to match
return {'type': 'imdb', 'id':title[5:]}
return None
def _get_movie(mid, language=None, search=False):
details = None if search else \
'trailers,images,releases,casts,keywords' if language is not None else \
'trailers'
response = tmdbapi.get_movie(mid, language=language, append_to_response=details)
theerror = response.get('error')
if theerror:
return 'error: {}'.format(theerror)
else:
return response
def _get_moviecollection(collection_id, language=None):
if not collection_id:
return None
details = 'images'
response = tmdbapi.get_collection(collection_id, language=language, append_to_response=details)
theerror = response.get('error')
if theerror:
return 'error: {}'.format(theerror)
else:
return response
def _parse_artwork(movie, collection, urlbases, language):
if language:
# Image languages don't have regional variants
language = language.split('-')[0]
posters = []
landscape = []
fanart = []
if 'images' in movie:
posters = _get_images_with_fallback(movie['images']['posters'], urlbases, language)
landscape = _get_images(movie['images']['backdrops'], urlbases, language)
fanart = _get_images(movie['images']['backdrops'], urlbases, None)
setposters = []
setlandscape = []
setfanart = []
if collection and 'images' in collection:
setposters = _get_images_with_fallback(collection['images']['posters'], urlbases, language)
setlandscape = _get_images(collection['images']['backdrops'], urlbases, language)
setfanart = _get_images(collection['images']['backdrops'], urlbases, None)
return {'poster': posters, 'landscape': landscape, 'fanart': fanart,
'set.poster': setposters, 'set.landscape': setlandscape, 'set.fanart': setfanart}
def _get_images_with_fallback(imagelist, urlbases, language, language_fallback='en'):
images = _get_images(imagelist, urlbases, language)
# Add backup images
if language != language_fallback:
images.extend(_get_images(imagelist, urlbases, language_fallback))
# Add any images if nothing set so far
if not images:
images = _get_images(imagelist, urlbases)
return images
def _get_images(imagelist, urlbases, language='_any'):
result = []
for img in imagelist:
if language != '_any' and img['iso_639_1'] != language:
continue
result.append({
'url': urlbases['original'] + img['file_path'],
'preview': urlbases['preview'] + img['file_path'],
})
return result
def _get_date_numeric(datetime_):
return (datetime_ - datetime(1970, 1, 1)).total_seconds()
def _load_base_urls(url_settings):
urls = {}
urls['original'] = url_settings.getSettingString('originalUrl')
urls['preview'] = url_settings.getSettingString('previewUrl')
last_updated = url_settings.getSettingString('lastUpdated')
if not urls['original'] or not urls['preview'] or not last_updated or \
float(last_updated) < _get_date_numeric(datetime.now() - timedelta(days=30)):
conf = tmdbapi.get_configuration()
if conf:
urls['original'] = conf['images']['secure_base_url'] + 'original'
urls['preview'] = conf['images']['secure_base_url'] + 'w780'
url_settings.setSetting('originalUrl', urls['original'])
url_settings.setSetting('previewUrl', urls['preview'])
url_settings.setSetting('lastUpdated', str(_get_date_numeric(datetime.now())))
return urls
def _parse_trailer(trailers, fallback):
if trailers.get('youtube'):
return 'plugin://plugin.video.youtube/?action=play_video&videoid='+trailers['youtube'][0]['source']
if fallback.get('youtube'):
return 'plugin://plugin.video.youtube/?action=play_video&videoid='+fallback['youtube'][0]['source']
return None
def _get_names(items):
return [item['name'] for item in items] if items else []
def _get_cast_members(casts, casttype, department, jobs):
result = []
if casttype in casts:
for cast in casts[casttype]:
if cast['department'] == department and cast['job'] in jobs and cast['name'] not in result:
result.append(cast['name'])
return result
================================================
FILE: metadata.douban.com.python/python/lib/tmdbscraper/tmdbapi.py
================================================
# -*- coding: UTF-8 -*-
#
# Copyright (C) 2020, Team Kodi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# pylint: disable=missing-docstring
"""Functions to interact with TMDb API."""
from . import api_utils
import xbmc
try:
from typing import Optional, Text, Dict, List, Any # pylint: disable=unused-import
InfoType = Dict[Text, Any] # pylint: disable=invalid-name
except ImportError:
pass
HEADERS = (
('User-Agent', 'Kodi Movie scraper by Team Kodi'),
('Accept', 'application/json'),
)
api_utils.set_headers(dict(HEADERS))
TMDB_PARAMS = {'api_key': 'f090bb54758cabf231fb605d3e3e0468'}
BASE_URL = 'https://api.themoviedb.org/3/{}'
SEARCH_URL = BASE_URL.format('search/movie')
FIND_URL = BASE_URL.format('find/{}')
MOVIE_URL = BASE_URL.format('movie/{}')
COLLECTION_URL = BASE_URL.format('collection/{}')
CONFIG_URL = BASE_URL.format('configuration')
def search_movie(query, year=None, language=None):
# type: (Text) -> List[InfoType]
"""
Search for a movie
:param title: movie title to search
:param year: the year to search (optional)
:param language: the language filter for TMDb (optional)
:return: a list with found movies
"""
xbmc.log('using title of %s to find movie' % query, xbmc.LOGDEBUG)
theurl = SEARCH_URL
params = _set_params(None, language)
params['query'] = query
if year is not None:
params['year'] = str(year)
return api_utils.load_info(theurl, params=params)
def find_movie_by_external_id(external_id, language=None):
# type: (Text) -> List[InfoType]
"""
Find movie based on external ID
:param mid: external ID
:param language: the language filter for TMDb (optional)
:return: the movie or error
"""
xbmc.log('using external id of %s to find movie' % external_id, xbmc.LOGDEBUG)
theurl = FIND_URL.format(external_id)
params = _set_params(None, language)
params['external_source'] = 'imdb_id'
return api_utils.load_info(theurl, params=params)
def get_movie(mid, language=None, append_to_response=None):
# type: (Text) -> List[InfoType]
"""
Get movie details
:param mid: TMDb movie ID
:param language: the language filter for TMDb (optional)
:append_to_response: the additional data to get from TMDb (optional)
:return: the movie or error
"""
xbmc.log('using movie id of %s to get movie details' % mid, xbmc.LOGDEBUG)
theurl = MOVIE_URL.format(mid)
return api_utils.load_info(theurl, params=_set_params(append_to_response, language))
def get_collection(collection_id, language=None, append_to_response=None):
# type: (Text) -> List[InfoType]
"""
Get movie collection information
:param collection_id: TMDb collection ID
:param language: the language filter for TMDb (optional)
:append_to_response: the additional data to get from TMDb (optional)
:return: the movie or error
"""
xbmc.log('using collection id of %s to get collection details' % collection_id, xbmc.LOGDEBUG)
theurl = COLLECTION_URL.format(collection_id)
return api_utils.load_info(theurl, params=_set_params(append_to_response, language))
def get_configuration():
# type: (Text) -> List[InfoType]
"""
Get configuration information
:return: configuration details or error
"""
xbmc.log('getting configuration details', xbmc.LOGDEBUG)
return api_utils.load_info(CONFIG_URL, params=TMDB_PARAMS.copy())
def _set_params(append_to_response, language):
params = TMDB_PARAMS.copy()
img_lang = 'en,null'
if language is not None:
params['language'] = language
img_lang = '%s,en,null' % language[0:2]
if append_to_response is not None:
params['append_to_response'] = append_to_response
if 'images' in append_to_response:
params['include_image_language'] = img_lang
return params
================================================
FILE: metadata.douban.com.python/python/lib/tmdbscraper/traktratings.py
================================================
# -*- coding: UTF-8 -*-
#
# Copyright (C) 2020, Team Kodi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
# pylint: disable=missing-docstring
"""Functions to interact with Trakt API."""
from __future__ import absolute_import, unicode_literals
from . import api_utils
from . import get_imdb_id
try:
from typing import Optional, Text, Dict, List, Any # pylint: disable=unused-import
InfoType = Dict[Text, Any] # pylint: disable=invalid-name
except ImportError:
pass
HEADERS = (
('User-Agent', 'Kodi Movie scraper by Team Kodi'),
('Accept', 'application/json'),
('trakt-api-key', '5f2dc73b6b11c2ac212f5d8b4ec8f3dc4b727bb3f026cd254d89eda997fe64ae'),
('trakt-api-version', '2'),
('Content-Type', 'application/json'),
)
api_utils.set_headers(dict(HEADERS))
MOVIE_URL = 'https://api.trakt.tv/movies/{}'
def get_trakt_ratinginfo(uniqueids):
imdb_id = get_imdb_id(uniqueids)
result = {}
url = MOVIE_URL.format(imdb_id)
params = {'extended': 'full'}
movie_info = api_utils.load_info(url, params=params, default={})
if(movie_info):
if 'votes' in movie_info and 'rating' in movie_info:
result['ratings'] = {'trakt': {'votes': int(movie_info['votes']), 'rating': float(movie_info['rating'])}}
elif 'rating' in movie_info:
result['ratings'] = {'trakt': {'rating': float(movie_info['rating'])}}
return result
================================================
FILE: metadata.douban.com.python/python/scraper.py
================================================
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import json
import sys
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin
from lib.tmdbscraper.tmdb import TMDBMovieScraper
from lib.tmdbscraper.fanarttv import get_details as get_fanarttv_artwork
from lib.tmdbscraper.imdbratings import get_details as get_imdb_details
from lib.tmdbscraper.traktratings import get_trakt_ratinginfo
from scraper_datahelper import combine_scraped_details_info_and_ratings, \
combine_scraped_details_available_artwork, find_uniqueids_in_text, get_params
from scraper_config import configure_scraped_details, PathSpecificSettings, \
configure_tmdb_artwork, is_fanarttv_configured
from xbmcswift2 import Plugin
import requests
from bs4 import BeautifulSoup
import re
from requests.adapters import HTTPAdapter
ADDON_SETTINGS = xbmcaddon.Addon('metadata.douban.com.python')
ID = ADDON_SETTINGS.getAddonInfo('id')
def log(msg, level=xbmc.LOGDEBUG):
xbmc.log(msg='[{addon}]: {msg}'.format(addon=ID, msg=msg), level=level)
headers = {
# 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
# 'Accept-Language': 'zh-CN,zh;q=0.9',
# 'Cache-Control': 'max-age=0',
# 'Connection': 'keep-alive',
# 'Sec-Fetch-User': '?1',
# 'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'
}
plugin = Plugin()
# @plugin.cached(TTL=2)
def get_html(url, ua='pc', cookie='', mode='html', encode='utf-8'):
#ConnectionError
cloudflare = ADDON_SETTINGS.getSetting('cloudflareproxy')
cloudflareurl = ADDON_SETTINGS.getSetting('cloudflareproxyurl')
# dialog = xbmcgui.Dialog()
# dialog.textviewer('错误提示', str(cloudflare))
# dialog = xbmcgui.Dialog()
# dialog.textviewer('错误提示', str(cloudflareurl))
if cloudflare == 'true':
if cloudflareurl[-1:] == '/':
url = cloudflareurl + '-----' + url
else:
url = cloudflareurl + '/-----' + url
else:
dialog = xbmcgui.Dialog()
dialog.notification('警告', '未设置代理Url可能使你的IP被豆瓣封禁',
xbmcgui.NOTIFICATION_WARNING, 5000, False)
if cookie != '':
cookie = eval(cookie)
else:
cookie = {}
# UA相关
head = headers
# 超时重试3次
# s0 = requests.Session()
with requests.Session() as s0:
s0.mount('http://', HTTPAdapter(max_retries=3))
s0.mount('https://', HTTPAdapter(max_retries=3))
# 获取网页源代码
if mode == 'html':
r = s0.get(url, headers=head, cookies=cookie, timeout=15)
# 编码相关
if encode == 'utf-8':
r.encoding = 'utf-8'
if encode == 'gbk':
r.encoding = 'gbk'
html = r.text
# 用于获取302跳转网页的真实url
if mode == 'url':
head['Connection'] = 'close'
r = s0.get(url, headers=head, timeout=5,
stream=True, cookies=cookie)
html = r.url
# dialog = xbmcgui.Dialog()
# dialog.textviewer('错误提示', str(url))
# dialog = xbmcgui.Dialog()
# dialog.textviewer('错误提示', str(html.encode('utf-8')))
return html
#获取视频真实url
def get_douban_videourl(url):
r = get_html(url)
soup = BeautifulSoup(r, 'html.parser')
video = False
counter = 1
while soup.find('source', type="video/mp4") == False:
r = get_html(url)
soup = BeautifulSoup(r, 'html.parser')
counter += 1
if counter > 3:
break
if soup.find('source', type="video/mp4"):
video = soup.find('source', type="video/mp4")['src']
break
return video
def get_douban_imglist(url):
r = get_html(url)
soup = BeautifulSoup(r, 'html.parser')
ul = soup.find('ul', class_='poster-col3')
li = ul.find_all('li')
returnlist = []
for index in range(len(li)):
imgdict = {}
img = li[index].find('img')['src']
imgdict['preview'] = img
img = re.sub('photo\/m', 'photo/r', img)
imgdict['url'] = img
returnlist.append(imgdict)
return returnlist
# 构造仿tmdb的json
# [{
# "poster_path": "https://1.jpg",
# "title": "标题",
# "release_date": "2019-06-19",
# "id": 568160
# }]
# def get_douban_search(title, year):
# #r = get_html("https://search.douban.com/movie/subject_search?cat=1002&search_text=" + title)
# r = get_html("https://www.douban.com/search?cat=1002&q=" + title)
# #print(r.encode('utf-8'))
# dialog = xbmcgui.Dialog()
# dialog.textviewer('search', str(r.encode('utf-8')))
# soup = BeautifulSoup(r, 'html.parser')
# result = soup.find("div", class_="result-list")
# resultlist = result.find_all('div', class_='result')
# returnlist = []
# for index in range(len(resultlist)):
# returndict = {}
# returndict['title'] = resultlist[index].find(
# 'div', class_="title").a.text
# returndict['poster_path'] = resultlist[index].find(
# 'div', class_="pic").a.img['src']
# returndict['release_date'] = re.search(
# '(?<=/ )[\d]{4}$', resultlist[index].find('span', class_="subject-cast").text).group()
# returndict['id'] = re.search(
# '(?<=sid: )[\d]+', resultlist[index].find('div', class_="pic").a['onclick']).group()
# returnlist.append(returndict)
# return returnlist
def get_douban_search(title, year):
r = get_html('https://movie.douban.com/j/subject_suggest?q=' + title)
j = json.loads(r)
returnlist = []
for index in range(len(j)):
returndict = {}
returndict['title'] = j[index]['sub_title']
returndict['poster_path'] = j[index]['img'].replace(
's_ratio_poster', 'r')
returndict['release_date'] = j[index]['year'] + '-01-01'
returndict['id'] = j[index]['id']
returnlist.append(returndict)
return returnlist
# 用douban的数据,构造仿tmdb的json
def get_douban_details(input_uniqueids):
doubanjson = {
"info": {
"mpaa": "PG-13",
"studio": ["豆瓣电影"],
"tag": [],
"trailer":""
},
"ratings": {
"themoviedb": {}
},
"available_art": {
"set.landscape": [],
"set.fanart": [],
"set.poster": [],
"fanart": [],
"poster": [],
"landscape": []
},
"uniqueids": {},
"cast": [],
"_info": {
"set_tmdbid": None
}}
#传入input_uniqueids = {'tmdb':'123456'}
doubanid = int(input_uniqueids['tmdb'])
doubanjson['uniqueids']['tmdb'] = doubanid
doubanurl = 'http://movie.douban.com/subject/' + str(doubanid) + '/'
r = get_html(doubanurl)
print(r.encode('utf-8'))
soup = BeautifulSoup(r, 'html.parser')
# 国家
countrys = []
info = soup.find('div',id='info')
country = re.search(r'(?<=制片国家/地区:).*?(?= )',str(info)).group()
# country = '日本'
if re.search('/', country):
country = country.split('/')
for i in range(len(country)):
countrys.append(country[i].strip())
else:
countrys.append(country.strip())
doubanjson['info']['country'] = countrys
# 标题&年
doubanjson['info']['title'] = soup.find(
'span', property="v:itemreviewed").text
#year = soup.find('span',class_="year").text.replace('(','').replace(')','')
# 豆瓣评分&人数
doubanjson['ratings']['themoviedb']['rating'] = float(
soup.find('strong', class_="ll rating_num").text)
doubanjson['ratings']['themoviedb']['votes'] = int(
soup.find('span', property="v:votes").text)
# 简介
doubanjson['info']['plot'] = soup.find(
'span', property="v:summary").text.strip()
# 预告片
if get_douban_videourl(soup.find('a', title="预告片")['href']):
trailer = get_douban_videourl(soup.find('a', title="预告片")['href']) + '|referer=' + doubanurl
doubanjson['info']['trailer'] = trailer
# 类型
genre = soup.find_all('span', property="v:genre")
genres = []
for i in range(len(genre)):
genres.append(genre[i].text)
doubanjson['info']['genre'] = genres
# 时长
doubanjson['info']['duration'] = int(
soup.find('span', property="v:runtime")['content'])*60
# 日期
doubanjson['info']['premiered'] = re.search(
'[\d]{4}-[\d]{2}-[\d]{2}', soup.find('span', property="v:initialReleaseDate")['content']).group()
# 标签
taglist = []
tag = soup.find('div', class_='tags-body')
tags = tag.find_all('a')
for i in range(len(tags)):
taglist.append(tags[i].text)
doubanjson['info']['tag'] = taglist
# 剧照
doubanjson['available_art']['fanart'] = get_douban_imglist('https://movie.douban.com/subject/' + str(doubanid) + '/photos?type=S')
# 海报
doubanjson['available_art']['poster'] = get_douban_imglist('https://movie.douban.com/subject/' + str(doubanid) + '/photos?type=R')
# 导演&编剧&演员
r = get_html("https://movie.douban.com/subject/" +
str(doubanid) + "/celebrities")
soup = BeautifulSoup(r, 'html.parser')
director = []
credit = []
cast = []
celebrities = soup.find('div', id='celebrities').find_all(
'div', class_='list-wrapper')
for index in range(len(celebrities)):
if celebrities[index].h2.text == u'导演 Director':
li = celebrities[index].find_all('li')
for i in range(len(li)):
director.append(li[i].a['title'])
if celebrities[index].h2.text == u'编剧 Writer':
li = celebrities[index].find_all('li')
for i in range(len(li)):
credit.append(li[i].a['title'])
if celebrities[index].h2.text == u'演员 Cast':
li = celebrities[index].find_all('li')
for i in range(len(li)):
castdict = {}
castdict['order'] = i
castdict['role'] = li[i].find('span', class_='role')['title']
castdict['name'] = li[i].a['title']
castdict['thumbnail'] = li[i].a.div['style'].replace(
'background-image: url(', '').replace(')', '').replace('s_ratio_celebrity', 'r')
cast.append(castdict)
doubanjson['info']['director'] = director
doubanjson['info']['credits'] = credit
doubanjson['cast'] = cast
return doubanjson
def get_tmdb_scraper(settings):
language = settings.getSettingString('language')
certcountry = settings.getSettingString('tmdbcertcountry')
# dialog = xbmcgui.Dialog()
# #dialog.notification('提示', '已关闭', xbmcgui.NOTIFICATION_INFO, 5000)
# dialog.textviewer('提示', str(TMDBMovieScraper(ADDON_SETTINGS, language, certcountry)))
return TMDBMovieScraper(ADDON_SETTINGS, language, certcountry)
def search_for_movie(title, year, handle, settings):
# 刮削&搜索
log("Find movie with title '{title}' from year '{year}'".format(
title=title, year=year), xbmc.LOGINFO)
title = _strip_trailing_article(title)
# 输出json结果
search_results = get_douban_search(title, year)
#search_results = get_tmdb_scraper(settings).search(title, year)
#dialog = xbmcgui.Dialog()
#dialog.textviewer('提示', str(get_tmdb_scraper(settings).search(title, year)))
if not search_results:
return
# if 'error' in search_results:
# header = "The Movie Database Python error searching with web service TMDB"
# xbmcgui.Dialog().notification(header, search_results['error'], xbmcgui.NOTIFICATION_WARNING)
# log(header + ': ' + search_results['error'], xbmc.LOGWARNING)
# return
for movie in search_results:
listitem = _searchresult_to_listitem(movie)
uniqueids = {'tmdb': str(movie['id'])}
xbmcplugin.addDirectoryItem(handle=handle, url=build_lookup_string(uniqueids),
listitem=listitem, isFolder=True)
_articles = [
prefix + article for prefix in (', ', ' ') for article in ("the", "a", "an")]
def _strip_trailing_article(title):
title = title.lower()
for article in _articles:
if title.endswith(article):
return title[:-len(article)]
return title
def _searchresult_to_listitem(movie):
# 显示搜索结果 天气之子(2019)
movie_info = {'title': movie['title']}
movie_label = movie['title']
movie_year = movie['release_date'].split(
'-')[0] if movie.get('release_date') else None
if movie_year:
movie_label += ' ({})'.format(movie_year)
movie_info['year'] = movie_year
listitem = xbmcgui.ListItem(movie_label, offscreen=True)
listitem.setInfo('video', movie_info)
if movie['poster_path']:
listitem.setArt({'thumb': movie['poster_path']})
# dialog = xbmcgui.Dialog()
# dialog.textviewer('提示111', str(movie_info))
return listitem
# Low limit because a big list of artwork can cause trouble in some cases
# (a column can be too large for the MySQL integration),
# and how useful is a big list anyway? Not exactly rhetorical, this is an experiment.
IMAGE_LIMIT = 10
def add_artworks(listitem, artworks):
for arttype, artlist in artworks.items():
if arttype == 'fanart':
continue
for image in artlist[:IMAGE_LIMIT]:
listitem.addAvailableArtwork(image['url'], arttype)
fanart_to_set = [{'image': image['url'], 'preview': image['preview']}
for image in artworks['fanart'][:IMAGE_LIMIT]]
listitem.setAvailableFanart(fanart_to_set)
def get_details(input_uniqueids, handle, settings):
# 解析详细信息
if not input_uniqueids:
return False
#details = get_tmdb_scraper(settings).get_details(input_uniqueids)
#传入input_uniqueids = {'tmdb':'123456'}
details = get_douban_details(input_uniqueids)
# dialog = xbmcgui.Dialog()
# dialog.textviewer('details', str(input_uniqueids))
if not details:
return False
# if 'error' in details:
# header = "The Movie Database Python error with web service TMDB"
# xbmcgui.Dialog().notification(header, details['error'], xbmcgui.NOTIFICATION_WARNING)
# log(header + ': ' + details['error'], xbmc.LOGWARNING)
# return False
# details = configure_tmdb_artwork(details, settings)
if settings.getSettingString('RatingS') == 'IMDb' or settings.getSettingBool('imdbanyway'):
imdbinfo = get_imdb_details(details['uniqueids'])
if 'error' in imdbinfo:
header = "The Movie Database Python error with website IMDB"
log(header + ': ' + imdbinfo['error'], xbmc.LOGWARNING)
else:
details = combine_scraped_details_info_and_ratings(
details, imdbinfo)
if settings.getSettingString('RatingS') == 'Trakt' or settings.getSettingBool('traktanyway'):
traktinfo = get_trakt_ratinginfo(details['uniqueids'])
details = combine_scraped_details_info_and_ratings(details, traktinfo)
if is_fanarttv_configured(settings):
fanarttv_info = get_fanarttv_artwork(details['uniqueids'],
settings.getSettingString(
'fanarttv_clientkey'),
settings.getSettingString(
'fanarttv_language'),
details['_info']['set_tmdbid'])
details = combine_scraped_details_available_artwork(
details, fanarttv_info)
details = configure_scraped_details(details, settings)
listitem = xbmcgui.ListItem(details['info']['title'], offscreen=True)
listitem.setInfo('video', details['info'])
listitem.setCast(details['cast'])
listitem.setUniqueIDs(details['uniqueids'], 'tmdb')
add_artworks(listitem, details['available_art'])
for rating_type, value in details['ratings'].items():
if 'votes' in value:
listitem.setRating(
rating_type, value['rating'], value['votes'], value['default'])
else:
listitem.setRating(
rating_type, value['rating'], defaultt=value['default'])
xbmcplugin.setResolvedUrl(handle=handle, succeeded=True, listitem=listitem)
return True
def find_uniqueids_in_nfo(nfo, handle):
uniqueids = find_uniqueids_in_text(nfo)
if uniqueids:
listitem = xbmcgui.ListItem(offscreen=True)
xbmcplugin.addDirectoryItem(
handle=handle, url=build_lookup_string(uniqueids), listitem=listitem, isFolder=True)
def build_lookup_string(uniqueids):
return json.dumps(uniqueids)
def parse_lookup_string(uniqueids):
try:
return json.loads(uniqueids)
except ValueError:
log("Can't parse this lookup string, is it from another add-on?\n" +
uniqueids, xbmc.LOGWARNING)
return None
def run():
params = get_params(sys.argv[1:])
enddir = True
if 'action' in params:
settings = ADDON_SETTINGS if not params.get('pathSettings') else \
PathSpecificSettings(json.loads(
params['pathSettings']), lambda msg: log(msg, xbmc.LOGWARNING))
action = params["action"]
if action == 'find' and 'title' in params:
search_for_movie(params["title"], params.get(
"year"), params['handle'], settings)
elif action == 'getdetails' and 'url' in params:
enddir = not get_details(parse_lookup_string(
params["url"]), params['handle'], settings)
elif action == 'NfoUrl' and 'nfo' in params:
find_uniqueids_in_nfo(params["nfo"], params['handle'])
else:
log("unhandled action: " + action, xbmc.LOGWARNING)
else:
log("No action in 'params' to act on", xbmc.LOGWARNING)
if enddir:
xbmcplugin.endOfDirectory(params['handle'])
if __name__ == '__main__':
run()
================================================
FILE: metadata.douban.com.python/python/scraper_config.py
================================================
def configure_scraped_details(details, settings):
details = _configure_rating_prefix(details, settings)
details = _configure_keeporiginaltitle(details, settings)
details = _configure_trailer(details, settings)
details = _configure_multiple_studios(details, settings)
details = _configure_default_rating(details, settings)
details = _configure_tags(details, settings)
return details
def configure_tmdb_artwork(details, settings):
if 'available_art' not in details:
return details
art = details['available_art']
fanart_enabled = settings.getSettingBool('fanart')
if not fanart_enabled:
if 'fanart' in art:
del art['fanart']
if 'set.fanart' in art:
del art['set.fanart']
if not settings.getSettingBool('landscape'):
if 'landscape' in art:
if fanart_enabled:
art['fanart'] = art.get('fanart', []) + art['landscape']
del art['landscape']
if 'set.landscape' in art:
if fanart_enabled:
art['set.fanart'] = art.get('set.fanart', []) + art['set.landscape']
del art['set.landscape']
return details
def is_fanarttv_configured(settings):
return settings.getSettingBool('enable_fanarttv_artwork')
def _configure_rating_prefix(details, settings):
if details['info'].get('mpaa'):
details['info']['mpaa'] = settings.getSettingString('certprefix') + details['info']['mpaa']
return details
def _configure_keeporiginaltitle(details, settings):
if settings.getSettingBool('keeporiginaltitle'):
details['info']['title'] = details['info']['originaltitle']
return details
def _configure_trailer(details, settings):
# if details['info'].get('trailer') and not settings.getSettingBool('trailer'):
# del details['info']['trailer']
return details
def _configure_multiple_studios(details, settings):
if not settings.getSettingBool('multiple_studios'):
details['info']['studio'] = details['info']['studio'][:1]
return details
def _configure_default_rating(details, settings):
imdb_default = bool(details['ratings'].get('imdb')) and settings.getSettingString('RatingS') == 'IMDb'
trakt_default = bool(details['ratings'].get('trakt')) and settings.getSettingString('RatingS') == 'Trakt'
default_rating = 'themoviedb'
if imdb_default:
default_rating = 'imdb'
elif trakt_default:
default_rating = 'trakt'
if default_rating not in details['ratings']:
default_rating = list(details['ratings'].keys())[0] if details['ratings'] else None
for rating_type in details['ratings'].keys():
details['ratings'][rating_type]['default'] = rating_type == default_rating
return details
def _configure_tags(details, settings):
# if not settings.getSettingBool('add_tags'):
# del details['info']['tag']
return details
# pylint: disable=invalid-name
try:
basestring
except NameError: # py2 / py3
basestring = str
#pylint: disable=redefined-builtin
class PathSpecificSettings(object):
# read-only shim for typed `xbmcaddon.Addon().getSetting*` methods
def __init__(self, settings_dict, log_fn):
self.data = settings_dict
self.log = log_fn
def getSettingBool(self, id):
return self._inner_get_setting(id, bool, False)
def getSettingInt(self, id):
return self._inner_get_setting(id, int, 0)
def getSettingNumber(self, id):
return self._inner_get_setting(id, float, 0.0)
def getSettingString(self, id):
return self._inner_get_setting(id, basestring, '')
def _inner_get_setting(self, setting_id, setting_type, default):
value = self.data.get(setting_id)
if isinstance(value, setting_type):
return value
self._log_bad_value(value, setting_id)
return default
def _log_bad_value(self, value, setting_id):
if value is None:
self.log("requested setting ({0}) was not found.".format(setting_id))
else:
self.log('failed to load value "{0}" for setting {1}'.format(value, setting_id))
================================================
FILE: metadata.douban.com.python/python/scraper_datahelper.py
================================================
import re
try:
from urlparse import parse_qsl
except ImportError: # py2 / py3
from urllib.parse import parse_qsl
# get addon params from the plugin path querystring
def get_params(argv):
result = {'handle': int(argv[0])}
if len(argv) < 2 or not argv[1]:
return result
result.update(parse_qsl(argv[1].lstrip('?')))
return result
def combine_scraped_details_info_and_ratings(original_details, additional_details):
def update_or_set(details, key, value):
if key in details:
details[key].update(value)
else:
details[key] = value
if additional_details:
if additional_details.get('info'):
update_or_set(original_details, 'info', additional_details['info'])
if additional_details.get('ratings'):
update_or_set(original_details, 'ratings', additional_details['ratings'])
return original_details
def combine_scraped_details_available_artwork(original_details, additional_details):
if additional_details and additional_details.get('available_art'):
available_art = additional_details['available_art']
if not original_details.get('available_art'):
original_details['available_art'] = available_art
else:
for arttype, artlist in available_art.items():
original_details['available_art'][arttype] = \
artlist + original_details['available_art'].get(arttype, [])
return original_details
def find_uniqueids_in_text(input_text):
result = {}
res = re.search(r'(themoviedb.org/movie/)([0-9]+)', input_text)
if (res):
result['tmdb'] = res.group(2)
res = re.search(r'imdb....?/title/tt([0-9]+)', input_text)
if (res):
result['imdb'] = 'tt' + res.group(1)
else:
res = re.search(r'imdb....?/Title\?t{0,2}([0-9]+)', input_text)
if (res):
result['imdb'] = 'tt' + res.group(1)
return result
================================================
FILE: metadata.douban.com.python/resources/language/Chinese (Simple)/strings.po
================================================
msgid ""
msgstr ""
#Chinese Simplified
msgctxt "#33001"
msgid "proxy"
msgstr "代理设置"
msgctxt "#33002"
msgid "cloudflareproxy"
msgstr "启用豆瓣代理(cloudflare worker)"
msgctxt "#33003"
msgid "cloudflareproxyurl"
msgstr "代理url"
================================================
FILE: metadata.douban.com.python/resources/settings.xml
================================================
================================================
FILE: plugin.audio.jsososo/addon.py
================================================
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import re
from xbmcswift2 import Plugin, xbmcgui, xbmc, xbmcaddon, xbmcplugin
#from xbmcswift2 import Actions
import requests
from bs4 import BeautifulSoup
import xbmcgui
import base64
import json
import urllib2
import sys
import HTMLParser
import re
import time
def unix_to_data(uptime,format='data'):
if len(str(uptime)) > 10:
uptime = str(uptime)[:-(len(str(uptime))-10)]
uptime = float(uptime)
time_local = time.localtime(uptime)
if format == 'data' or format == 'zhdata' or format == 'datatime' or format == 'zhdatatime' or format == 'time' or format == 'zhtime':
if format == 'data':
uptime = time.strftime('%Y-%m-%d',time_local)
if format == 'zhdata':
uptime = time.strftime('%Y年%m月%d日',time_local)
if format == 'datatime':
uptime = time.strftime('%Y-%m-%d %H:%M:%S',time_local)
if format == 'zhdatatime':
uptime = time.strftime('%Y年%m月%d日 %H时%M分%S秒',time_local)
if format == 'time':
uptime = time.strftime('%H:%M:%S',time_local)
if format == 'zhtime':
uptime = time.strftime('%H时%M分%S秒',time_local)
else:
uptime = time.strftime(format,time_local)
return uptime
#超过10000换算
def zh(num):
if int(num) >= 100000000:
p = round(float(num)/float(100000000), 1)
p = str(p) + '亿'
else:
if int(num) >= 10000:
p = round(float(num)/float(10000), 1)
p = str(p) + '万'
else:
p = str(num)
return p
def get_real_url(url):
rs = requests.get(url,headers=headers,timeout=2)
return rs.url
def unescape(string):
string = urllib2.unquote(string).decode('utf8')
quoted = HTMLParser.HTMLParser().unescape(string).encode('utf-8')
#转成中文
return re.sub(r'%u([a-fA-F0-9]{4}|[a-fA-F0-9]{2})', lambda m: unichr(int(m.group(1), 16)), quoted)
plugin = Plugin()
headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36'}
cache = plugin.get_storage('cache')
his = plugin.get_storage('his')
#初始化api
# if 'myqq' not in cache:
# cache['myqq'] = ''
# if 'my163' not in cache:
# cache['my163'] = ''
# if 'my163num' not in cache:
# cache['my163num'] = ''
# if 'myqqnum' not in cache:
# cache['myqqnum'] = ''
# xbmcplugin.setContent(int(sys.argv[1]), 'musicvideos')
netease_api = xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusicapiurl')
qqmusic_api = xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusicapiurl')
migu_api = xbmcplugin.getSetting(int(sys.argv[1]), 'miguapiurl')
@plugin.cached(TTL=1)
def get_html(url,cookie=''):
if cookie != '':
h = headers
h['cookie'] = cookie
r = requests.get(url,headers=h)
else:
r = requests.get(url,headers=headers)
return r.text
########################################### 为你推荐歌单api ###########################################
def one63weinituijian():
gedans = []
r = get_html(netease_api + '/recommend/resource','MUSIC_U=' + xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusicu'))
j = json.loads(r)
if j['code'] == 200:
glist = j['recommend']
for index in range(len(glist)):
desc = ''
if glist[index]['copywriter']:
desc += glist[index]['copywriter'].encode('utf-8')
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['picUrl']
gd['url'] = 'https://music.163.com/#/playlist?id=' + str(glist[index]['id'])
gd['info'] = {'plot':zh(glist[index]['playcount']) + ' 播放 · ' + zh(glist[index]['trackCount']) + ' 首歌\n\n' + desc}
gd['info']['cast'] = [(glist[index]['creator']['nickname'],unix_to_data(glist[index]['createTime']) + u'创建')]
gedans.append(gd)
return gedans
else:
if j['code'] == 301:
dialog = xbmcgui.Dialog()
dialog.notification('请求失败','请尝试更换MUSIC_U', xbmcgui.NOTIFICATION_INFO, 5000)
def qqweinituijian():
gedans = []
r = get_html(qqmusic_api + '/recommend/playlist/u')
j = json.loads(r)
glist = j['data']['list']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['title']
gd['thumb'] = glist[index]['cover']
gd['url'] = 'https://y.qq.com/n/yqq/playlist/' + str(glist[index]['content_id']) + '.html'
gd['info'] = {'plot':zh(glist[index]['listen_num']) + ' 播放量'}
gd['info']['cast']= [glist[index]['username']]
gedans.append(gd)
return gedans
########################################### 日推api ###########################################
def one63ritui():
gedans = []
r = get_html(netease_api + '/recommend/songs','MUSIC_U='+xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusicu'))
j = json.loads(r)
if j['code'] == 200:
gedans = []
glist = j['recommend']
# songs = ''
# for index in range(len(glist)):
# if index == 0:
# songs += str(glist[index]['id'])
# else:
# songs += ',' + str(glist[index]['id'])
# #mp3 url
# r2 = get_html(netease_api + '/song/url?id=' + songs)
# j2 = json.loads(r2)
# mp3urls = j2['data']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['album']['picUrl']
# gdurl = ''
# for i in range(len(mp3urls)):
# if int(mp3urls[i]['id']) == int(glist[index]['id']):
# gdurl = mp3urls[i]['url']
# if gdurl == '':
# gd['name'] += ' - [无版权]'
if xbmcplugin.getSetting(int(sys.argv[1]), 'httpswitch') == 'true':
gdurl = 'http'
else:
gdurl = 'https'
gdurl += '://music.163.com/song/media/outer/url?id='+str(glist[index]['id'])+'.mp3'
gd['url'] = gdurl
gd['info'] = {'title':glist[index]['name'],'album':glist[index]['album']['name'],'artist':glist[index]['artists'][0]['name'],'mediatype':'song'}
#gd['url'] = j2['data'][0]['url']
gedans.append(gd)
return gedans
else:
if j['code'] == 301:
dialog = xbmcgui.Dialog()
dialog.notification('请求失败','请尝试更换网易云音乐的 MUSIC_U', xbmcgui.NOTIFICATION_INFO, 5000)
def qqritui():
gedans = []
r = get_html(qqmusic_api + '/recommend/daily',xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusiccookie'))
j = json.loads(r)
if j['result'] == 100:
glist = j['data']['songlist']
songs= ''
for index in range(len(glist)):
if index == 0:
songs += glist[index]['songmid']
else:
songs += ',' + glist[index]['songmid']
r1 = get_html(qqmusic_api + '/song/urls?id=' + songs)
j1 = json.loads(r1)
mp3urls = j1['data']
for index in range(len(glist)):
if glist[index]['songmid'] in mp3urls:
gd ={}
gd['name'] = glist[index]['songname']
gd['thumb'] = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000' + glist[index]['albummid'] + '.jpg'
gd['url'] = mp3urls[glist[index]['songmid']]
gd['info'] = {'title':glist[index]['songname'],'album':glist[index]['albumname'],'artist':glist[index]['singer'][0]['name'],'mediatype':'song'}
gedans.append(gd)
return gedans
else:
if j['result'] == 301:
dialog = xbmcgui.Dialog()
dialog.notification('请求失败','请尝试更换QQ音乐的 cookie', xbmcgui.NOTIFICATION_INFO, 5000)
########################################### 我的歌单api ###########################################
def one63gedan():
gedans = []
r = get_html(netease_api + '/user/playlist?uid=' + str(xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusicuid')))
j = json.loads(r)
glist = j['playlist']
for index in range(len(glist)):
desc = ''
if glist[index]['description']:
desc += glist[index]['description'].encode('utf-8')
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['coverImgUrl']
gd['url'] = 'https://music.163.com/#/playlist?id=' + str(glist[index]['id'])
gd['info'] = {'plot':zh(glist[index]['playCount']) + ' 播放 · ' + zh(glist[index]['trackCount']) + ' 首歌\n\n' + desc}
gd['info']['cast'] = [(glist[index]['creator']['nickname'],unix_to_data(glist[index]['createTime']) + u'创建')]
gedans.append(gd)
return gedans
def qqgedan():
gedans = []
r = get_html(qqmusic_api + '/user/songlist?id=' + str(xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusicid')))
j = json.loads(r)
glist = j['data']['list']
for index in range(len(glist)):
if int(glist[index]['tid']) > 0:
gd ={}
gd['name'] = glist[index]['diss_name']
gd['thumb'] = glist[index]['diss_cover']
gd['url'] = 'https://y.qq.com/n/yqq/playlist/' + str(glist[index]['tid']) + '.html'
gd['info'] = {'plot':zh(glist[index]['listen_num']) + ' 播放 · ' + zh(glist[index]['song_cnt']) + ' 首歌'}
gd['info']['cast'] = [j['data']['creator']['hostname']]
gedans.append(gd)
return gedans
########################################### 推荐歌单api ###########################################
def one63tuijiangedan():
gedans = []
r = get_html(netease_api + '/personalized')
j = json.loads(r)
glist = j['result']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['picUrl']
gd['url'] = 'https://music.163.com/#/playlist?id=' + str(glist[index]['id'])
gd['info'] = {'plot':zh(glist[index]['playCount']) + ' 播放 · ' + zh(glist[index]['trackCount']) + ' 首歌\n\n' + glist[index]['copywriter'].encode('utf-8')}
gd['info']['cast'] = ['不知道是谁']
gedans.append(gd)
return gedans
def qqtuijiangedan():
gedans = []
r = get_html(qqmusic_api + '/recommend/playlist/')
j = json.loads(r)
glist = j['data']['list']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['title']
gd['thumb'] = glist[index]['cover_url_big']
gd['url'] = 'https://y.qq.com/n/yqq/playlist/' + str(glist[index]['tid']) + '.html'
gd['info'] = {'plot':zh(glist[index]['access_num']) + ' 播放量'}
gd['info']['cast']= [glist[index]['creator_info']['nick']]
gedans.append(gd)
return gedans
########################################### 歌单详细信息api ###########################################
def one63playlist(id):
gedans = []
r = get_html(netease_api + '/playlist/detail?id=' + str(id))
j = json.loads(r)
glist = j['playlist']['trackIds']
songs = ''
for index in range(len(glist)):
if index == 0:
songs += str(glist[index]['id'])
else:
songs += ',' + str(glist[index]['id'])
#mp3详情
r1 = get_html(netease_api + '/song/detail?ids=' + songs)
j1 = json.loads(r1)
mp3detail = j1['songs']
# #mp3 url
# r2 = get_html(netease_api + '/song/url?id=' + songs)
# j2 = json.loads(r2)
# mp3urls = j2['data']
# pDialog = xbmcgui.DialogProgress()
# pDialog.create('网易云音乐', '努力从母猪厂的土豆服务器偷mp3中...(0%)')
for index in range(len(mp3detail)):
# pDialog.update(int(100*(float(index)/float(len(mp3detail)))), '努力从母猪厂的土豆服务器偷mp3中...('+str(int(100*(float(index)/float(len(mp3detail)))))+'%)')
# #r2 = get_html(netease_api + '/song/url?id=' + str(mp3detail[index]['id']))
# #j2 = json.loads(r2)
gd ={}
gd['name'] = mp3detail[index]['name']
gd['thumb'] = mp3detail[index]['al']['picUrl']
# gdurl = ''
# for i in range(len(mp3urls)):
# if int(mp3urls[i]['id']) == int(mp3detail[index]['id']):
# gdurl = mp3urls[i]['url']
# if gdurl == '':
# gd['name'] += ' - [无版权]'
# gd['url'] = gdurl
if xbmcplugin.getSetting(int(sys.argv[1]), 'httpswitch') == 'true':
gd['url'] = 'http'
else:
gd['url'] = 'https'
gd['url'] += '://music.163.com/song/media/outer/url?id=' + str(mp3detail[index]['id']) + '.mp3'
gd['info'] = {'title':mp3detail[index]['name'],'album':mp3detail[index]['al']['name'],'artist':mp3detail[index]['ar'][0]['name'],'mediatype':'song'}
#gd['url'] = j2['data'][0]['url']
gedans.append(gd)
return gedans
def qqplaylist(id):
gedans = []
r = get_html(qqmusic_api + '/songlist?id=' + str(id))
j = json.loads(r)
glist = j['data']['songlist']
songs= ''
for index in range(len(glist)):
if index == 0:
songs += glist[index]['songmid']
else:
songs += ',' + glist[index]['songmid']
r1 = get_html(qqmusic_api + '/song/urls?id=' + songs)
j1 = json.loads(r1)
mp3urls = j1['data']
for index in range(len(glist)):
if glist[index]['songmid'] in mp3urls:
gd ={}
gd['name'] = glist[index]['songname']
gd['thumb'] = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000' + glist[index]['albummid'] + '.jpg'
gd['url'] = mp3urls[glist[index]['songmid']]
gd['info'] = {'title':glist[index]['songname'],'album':glist[index]['albumname'],'artist':glist[index]['singer'][0]['name'],'mediatype':'song'}
gedans.append(gd)
return gedans
########################################### 专辑详细信息api ###########################################
def one63album(id):
gedans = []
r = get_html(netease_api + '/playlist/detail?id=' + str(id))
j = json.loads(r)
glist = j['playlist']['trackIds']
songs = ''
for index in range(len(glist)):
if index == 0:
songs += str(glist[index]['id'])
else:
songs += ',' + str(glist[index]['id'])
#mp3详情
r1 = get_html(netease_api + '/song/detail?ids=' + songs)
j1 = json.loads(r1)
mp3detail = j1['songs']
# #mp3 url
# r2 = get_html(netease_api + '/song/url?id=' + songs)
# j2 = json.loads(r2)
# mp3url = j2['data']
for index in range(len(mp3detail)):
gd ={}
gd['name'] = mp3detail[index]['name']
gd['thumb'] = mp3detail[index]['al']['picUrl']
# gd['url'] = mp3url[index]['url']
if xbmcplugin.getSetting(int(sys.argv[1]), 'httpswitch') == 'true':
gd['url'] = 'http'
else:
gd['url'] = 'https'
gd['url'] += '://music.163.com/song/media/outer/url?id=' + str(mp3detail[index]['id']) + '.mp3'
gedans.append(gd)
return gedans
def qqalbum(id):
gedans = []
r = get_html(qqmusic_api + '/album/songs?albummid=' + str(id))
j = json.loads(r)
glist = j['data']['list']
songs= ''
for index in range(len(glist)):
if index == 0:
songs += glist[index]['mid']
else:
songs += ',' + glist[index]['mid']
r1 = get_html(qqmusic_api + '/song/urls?id=' + songs)
j1 = json.loads(r1)
mp3urls = j1['data']
for index in range(len(glist)):
if glist[index]['mid'] in mp3urls:
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000' + glist[index]['album']['mid'] + '.jpg'
gd['url'] = mp3urls[glist[index]['mid']]
gedans.append(gd)
return gedans
########################################### 歌手热门歌曲api ###########################################
def one63singer(id):
gedans = []
r = get_html(netease_api + '/artists?id=' + str(id))
j = json.loads(r)
glist = j['hotSongs']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['al']['picUrl']
#mp3 url
r2 = get_html(netease_api + '/song/url?id=' + str(glist[index]['id']))
j2 = json.loads(r2)
gd['url'] = j2['data'][0]['url']
gedans.append(gd)
return gedans
def qqsinger(id):
gedans = []
r = get_html(qqmusic_api + '/singer/songs?num=50&singermid=' + str(id))
j = json.loads(r)
glist = j['data']['list']
songs= ''
for index in range(len(glist)):
if index == 0:
songs += glist[index]['mid']
else:
songs += ',' + glist[index]['mid']
r1 = get_html(qqmusic_api + '/song/urls?id=' + songs)
j1 = json.loads(r1)
mp3urls = j1['data']
for index in range(len(glist)):
if glist[index]['mid'] in mp3urls:
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000' + glist[index]['album']['mid'] + '.jpg'
gd['url'] = mp3urls[glist[index]['mid']]
gedans.append(gd)
return gedans
########################################### 排行 ###########################################
def get_rank():
items = []
r1 = get_html(netease_api + '/toplist')
j1 = json.loads(r1)
one63list = j1['list']
for index in range(len(one63list)):
gd = {}
gd['name'] = u'网易云音乐 · '+ one63list[index]['name']
gd['thumb'] = one63list[index]['coverImgUrl']
gd['url'] = '163|' + str(one63list[index]['id'])
gd['desc'] = one63list[index]['description']
items.append(gd)
r2 = get_html(qqmusic_api + '/top/category')
j2 = json.loads(r2)
qqlist = j2['data']
for index in range(len(qqlist)):
listlist = qqlist[index]['list']
for i in range(len(listlist)):
if listlist[i]['topId'] != 201:
gd = {}
gd['name'] = u'QQ音乐 · '+ listlist[i]['label']
gd['thumb'] = listlist[i]['picUrl']
gd['url'] = 'qq|' + str(listlist[i]['topId'])
gd['desc'] = listlist[i]['updateTime'] + u'更新'
items.append(gd)
return items
########################################### 排行详细 ###########################################
def one63rank(value):
gedans = []
# r = get_html(netease_api + '/top/list?idx=' + value)
r = get_html(netease_api + '/related/playlist?id=' + value)
dialog = xbmcgui.Dialog()
dialog.textviewer('错误提示', str(value))
j = json.loads(r)
glist = j['playlist']['tracks']
# songs = ''
# for index in range(len(glist)):
# if index == 0:
# songs += str(glist[index]['id'])
# else:
# songs += ',' + str(glist[index]['id'])
# #mp3 url
# r2 = get_html(netease_api + '/song/url?id=' + songs)
# j2 = json.loads(r2)
# mp3url = j2['data']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['name']
gd['label'] = glist[index]['name']
if glist[index]['alia'] != []:
gd['label'] += u'(' + glist[index]['alia'][0] + u')'
gd['thumb'] = glist[index]['al']['picUrl']
# gd['url'] = mp3url[index]['url']
if xbmcplugin.getSetting(int(sys.argv[1]), 'httpswitch') == 'true':
gd['url'] = 'http'
else:
gd['url'] = 'https'
gd['url'] += '://music.163.com/song/media/outer/url?id=' + str(glist[index]['id']) + '.mp3'
gedans.append(gd)
return gedans
def qqrank(value):
gedans = []
# dialog = xbmcgui.Dialog()
# dialog.textviewer('错误提示', str(value))
r = get_html(qqmusic_api + '/top?id=' + str(value))
j = json.loads(r)
glist = j['data']['list']
songs= ''
for index in range(len(glist)):
if index == 0:
songs += glist[index]['mid']
else:
songs += ',' + glist[index]['mid']
r1 = get_html(qqmusic_api + '/song/urls?id=' + songs)
j1 = json.loads(r1)
mp3urls = j1['data']
for index in range(len(glist)):
if glist[index]['mid'] in mp3urls:
gd ={}
gd['name'] = glist[index]['title']
gd['label'] = ''
if int(glist[index]['rankType']) == 1:
gd['label'] += u'[COLOR red]↑ ' + glist[index]['rankValue'] + u' '*(3-len(str(glist[index]['rankValue']))) + u'[/COLOR]'
if int(glist[index]['rankType']) == 2:
gd['label'] += u'[COLOR green]↓ ' + glist[index]['rankValue'] + u' '*(3-len(str(glist[index]['rankValue']))) + u'[/COLOR]'
if int(glist[index]['rankType']) == 3:
gd['label'] += u'= ' + glist[index]['rankValue'] + u' '*(3-len(str(glist[index]['rankValue'])))
if int(glist[index]['rankType']) == 4:
gd['label'] += u'[COLOR red]NEW[/COLOR]'
if int(glist[index]['rankType']) == 6:
gd['label'] += u'[COLOR red]↑ ' + glist[index]['rankValue'] + u'[/COLOR]' + u' '*(5-len(str(glist[index]['rankValue'])))
gd['label'] += u' ' + glist[index]['title']
gd['thumb'] = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000' + glist[index]['albumMid'] + '.jpg'
gd['url'] = mp3urls[glist[index]['mid']]
gedans.append(gd)
return gedans
########################################### mv ###########################################
def one63mvlist(page):
items = []
r = get_html(netease_api + '/mv/all?limit=50&offset=' + str( ( int(page)-1 ) *50 ) )
j = json.loads(r)
one63list = j['data']
for index in range(len(one63list)):
gd = {}
gd['name'] = one63list[index]['name']
gd['thumb'] = one63list[index]['cover']
gd['url'] = 'https://music.163.com/#/mv?id=' +str(one63list[index]['id'])
items.append(gd)
return items
def qqmvlist(page):
items = []
r = get_html(qqmusic_api + '/mv/list?pageSize=50&pageNo=' + str(page))
j = json.loads(r)
listlist = j['data']['list']
for i in range(len(listlist)):
gd = {}
gd['name'] = listlist[i]['title']
gd['thumb'] = listlist[i]['picurl']
gd['url'] = 'https://y.qq.com/n/yqq/mv/v/'+listlist[i]['vid']+'.html'
items.append(gd)
return items
def one63playmv(vid):
r = get_html(netease_api + '/mv/url?id=' + str(vid))
j = json.loads(r)
mp4 = j['data']['url']
return mp4
def qqplaymv(vid):
r = get_html(qqmusic_api + '/mv/url?id=' + str(vid))
j = json.loads(r)
mp4 = j['data'][vid][len( j['data'][vid])-1]
return mp4
def one63mvinfo(vid):
vdict = {}
r = get_html(netease_api + '/mv/detail?mvid=' + str(vid))
j = json.loads(r)
i = j['data']
vdict['title'] = i['name']
vdict['thumb'] = i['cover']
vdict['duration'] = int(str(i['duration'])[:-3])
vdict['plot'] = zh(i['playCount']) + '播放 · ' + zh(i['commentCount']) + '评论'
if i['desc']:
vdict['plot'] += '\n\n' + i['desc'].encode('utf-8')
vdict['aired'] = i['publishTime']
cast = []
for index in range(len(i['artists'])):
cast.append(i['artists'][index]['name'])
vdict['cast'] = cast
return vdict
def qqmvinfo(vid):
vdict = {}
r = get_html(qqmusic_api + '/mv?id=' + str(vid))
j = json.loads(r)
i = j['data']['info']
vdict['title'] = i['name']
vdict['thumb'] = i['cover_pic']
vdict['duration'] = i['duration']
vdict['plot'] = zh(i['playcnt']) + '播放'
if i['desc']:
vdict['plot'] = i['desc']
vdict['aired'] = unix_to_data(i['pubdate'])
cast = []
for index in range(len(i['singers'])):
cast.append(i['singers'][index]['name'])
vdict['cast'] = cast
return vdict
########################################### 搜索 ###########################################
def one63search(keyword,type,page):
gedans = []
r = get_html(netease_api + '/search?keywords=' + keyword + '&offset='+str((int(page)-1)*30)+'&type='+type)
j = json.loads(r)
glist = j['result']
#单曲
if type == '1':
if 'songs' in glist:
glist = glist['songs']
songs= ''
for index in range(len(glist)):
if index == 0:
songs += str(glist[index]['id'])
else:
songs += ',' + str(glist[index]['id'])
#mp3详情
r2 = get_html(netease_api + '/song/detail?ids=' + songs)
j2 = json.loads(r2)
mp3detail = j2['songs']
for index in range(len(glist)):
gd ={}
gd['name'] = mp3detail[index]['name']
gd['thumb'] = mp3detail[index]['al']['picUrl']
#mp3url
r1 = get_html(netease_api + '/song/url?id=' + str(mp3detail[index]['id']))
j1 = json.loads(r1)
gdurl = j1['data'][0]['url']
gd['url'] = gdurl
#gd['url'] = mp3urls[str(mp3detail[index]['id'])]
gd['info'] = {'title':mp3detail[index]['name'],'album':mp3detail[index]['al']['name'],'artist':mp3detail[index]['ar'][0]['name']}
gedans.append(gd)
else:
dialog = xbmcgui.Dialog()
dialog.notification('提示', '搜索结果为空', xbmcgui.NOTIFICATION_INFO, 5000)
#歌单
if type == '1000':
if 'playlists' in glist:
glist = glist['playlists']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['coverImgUrl']
gd['url'] = 'https://music.163.com/#/playlist?id=' + str(glist[index]['id'])
ginfo = {'title':glist[index]['name'],'cast':[(glist[index]['creator']['nickname'],u'创建者')],'plot':zh(glist[index]['playCount']).decode('utf-8') + u'播放 · ' + zh(glist[index]['trackCount']).decode('utf-8') + u'首歌 \n\n'}
if glist[index]['description']:
ginfo['plot'] += glist[index]['description']
gd['info'] = ginfo
gedans.append(gd)
else:
dialog = xbmcgui.Dialog()
dialog.notification('提示', '搜索结果为空', xbmcgui.NOTIFICATION_INFO, 5000)
#专辑
if type == '10':
if 'albums' in glist:
glist = glist['albums']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['blurPicUrl']
gd['url'] = 'https://music.163.com/#/album?id=' + str(glist[index]['id'])
gd['info'] = {'title':glist[index]['name'],'album':glist[index]['name'],'artist':glist[index]['artists'][0]['name']}
gedans.append(gd)
else:
dialog = xbmcgui.Dialog()
dialog.notification('提示', '搜索结果为空', xbmcgui.NOTIFICATION_INFO, 5000)
#歌手
if type == '100':
if 'artists' in glist:
glist = glist['artists']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['picUrl']
gd['url'] = 'https://music.163.com/#/artist?id=' + str(glist[index]['id'])
gd['info'] = {'title':glist[index]['name'],'artist':glist[index]['name']}
gedans.append(gd)
else:
dialog = xbmcgui.Dialog()
dialog.notification('提示', '搜索结果为空', xbmcgui.NOTIFICATION_INFO, 5000)
#MV
if type == '1004':
if 'mvs' in glist:
glist = glist['mvs']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['name']
gd['thumb'] = glist[index]['cover']
gd['url'] = 'https://music.163.com/#/mv?id=' + str(glist[index]['id'])
gd['info'] = {'title':glist[index]['name'],'duration':int(glist[index]['duration'])/1000,'cast':[glist[index]['artistName']]}
gedans.append(gd)
else:
dialog = xbmcgui.Dialog()
dialog.notification('提示', '搜索结果为空', xbmcgui.NOTIFICATION_INFO, 5000)
#视频
if type == '1014':
if 'videos' in glist:
glist = glist['videos']
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['title']
gd['thumb'] = glist[index]['coverUrl']
gd['url'] = 'https://music.163.com/#/video?id=' + str(glist[index]['vid'])
gd['info'] = {'title':glist[index]['title'],'duration':int(glist[index]['durationms'])/1000,'cast':[glist[index]['creator'][0]['userName']]}
gedans.append(gd)
else:
dialog = xbmcgui.Dialog()
dialog.notification('提示', '搜索结果为空', xbmcgui.NOTIFICATION_INFO, 5000)
return gedans
def qqsearch(keyword,type,page):
gedans = []
r = get_html(qqmusic_api + '/search?key=' + keyword + '&pageSize=30&pageNo='+str(page)+'&t='+type)
j = json.loads(r)
glist = j['data']['list']
#单曲
if type == '0':
songs= ''
for index in range(len(glist)):
if index == 0:
songs += glist[index]['songmid']
else:
songs += ',' + glist[index]['songmid']
r1 = get_html(qqmusic_api + '/song/urls?id=' + songs)
j1 = json.loads(r1)
mp3urls = j1['data']
for index in range(len(glist)):
if glist[index]['songmid'] in mp3urls:
gd ={}
gd['name'] = glist[index]['songname']
gd['thumb'] = 'http://y.gtimg.cn/music/photo_new/T002R300x300M000' + glist[index]['albummid'] + '.jpg'
gd['url'] = mp3urls[glist[index]['songmid']]
gd['info'] = {'title':glist[index]['songname'],'album':glist[index]['albumname'],'artist':glist[index]['singer'][0]['name']}
gedans.append(gd)
#歌单
if type == '2':
for index in range(len(glist)):
gd ={}
gd['name'] = unescape(glist[index]['dissname'].encode('utf-8')).decode('utf-8')
gd['thumb'] = glist[index]['imgurl']
gd['url'] = 'https://y.qq.com/n/yqq/playlist/' + str(glist[index]['dissid']) + '.html'
gd['info'] = {'title':unescape(glist[index]['dissname'].encode('utf-8')).decode('utf-8'),'cast':[glist[index]['creator']['name'],u'创建者'],'plot':zh(glist[index]['listennum']).decode('utf-8') + u' 播放 \n\n' + unescape(glist[index]['introduction'].encode('utf-8')).decode('utf-8')}
gedans.append(gd)
#专辑
if type == '8':
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['albumName']
gd['thumb'] = glist[index]['albumPic']
gd['url'] = 'https://y.qq.com/n/yqq/album/' + str(glist[index]['albumMID']) + '.html'
gd['info'] = {'title':glist[index]['albumName'],'album':glist[index]['albumName'],'artist':glist[index]['singerName']}
gedans.append(gd)
#歌手
if type == '9':
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['singerName']
gd['thumb'] = glist[index]['singerPic']
gd['url'] = 'https://y.qq.com/n/yqq/singer/' + str(glist[index]['singerMID']) + '.html'
gd['info'] = {'title':glist[index]['singerName'],'artist':glist[index]['singerName']}
gedans.append(gd)
#MV
if type == '12':
for index in range(len(glist)):
gd ={}
gd['name'] = glist[index]['mv_name']
gd['thumb'] = glist[index]['mv_pic_url']
gd['url'] = 'https://y.qq.com/n/yqq/mv/v/' + str(glist[index]['v_id']) + '.html'
gd['info'] = {'title':glist[index]['mv_name'],'duration':glist[index]['duration']}
gedans.append(gd)
return gedans
########################################### 网易云视频 ###########################################
def one63playvideo(vid):
r = get_html(netease_api + '/video/url?id=' + str(vid))
j = json.loads(r)
mp4 = j['urls'][0]['url']
return mp4
def one63videoinfo(vid):
vdict = {}
r = get_html(netease_api + '/video/detail?id=' + str(vid))
j = json.loads(r)
i = j['data']
vdict['title'] = i['title']
vdict['thumb'] = i['coverUrl']
vdict['duration'] = int(i['durationms']/1000)
vdict['plot'] = zh(i['playTime']) + '播放 · ' + zh(i['praisedCount']) + '赞 · ' + zh(i['commentCount']) + '评论'
if i['description']:
vdict['plot'] += '\n\n' + i['description'].encode('utf-8')
vdict['aired'] = unix_to_data(i['publishTime'])
genre = []
for index in range(len(i['videoGroup'])):
genre.append(i['videoGroup'][index]['name'])
vdict['cast'] = [(i['creator']['nickname'],'视频作者')]
vdict['genre'] = genre
vdict['tag'] = genre
return vdict
@plugin.route('/')
def index():
items = []
items.append({
'label': '推荐',
'path': plugin.url_for('tuijian'),
})
items.append({
'label': '排行',
'path': plugin.url_for('rank'),
})
items.append({
'label': 'MV',
'path': plugin.url_for('mv'),
})
items.append({
'label': '搜索',
'path': plugin.url_for('so'),
})
items.append({
'label': '歌单',
'path': plugin.url_for('gedang'),
})
items.append({
'label': '日推',
'path': plugin.url_for('ritui'),
})
# items.append({
# 'label': '设置',
# 'path': plugin.url_for('setting'),
# })
return items
@plugin.route('/tuijian/')
def tuijian():
items = []
items.append({
'label': '网易云 · 热门推荐歌单',
'path': plugin.url_for('get_tuijian',mode='163'),
})
items.append({
'label': 'QQ音乐 · 热门推荐歌单',
'path': plugin.url_for('get_tuijian',mode='qq'),
})
return items
@plugin.route('/ritui/')
def ritui():
if xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusiccookieswitch') == 'true' or xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusiccookieswitch') == 'true':
items = []
if xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusicu') != '' and xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusiccookieswitch') == 'true':
items.append({
'label': '网易云 · 私人推荐',
'path': plugin.url_for('get_ritui',mode='163'),
})
if xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusiccookie') != '' and xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusiccookieswitch') == 'true':
items.append({
'label': 'QQ音乐 · 私人推荐',
'path': plugin.url_for('get_ritui',mode='qq'),
})
return items
else:
dialog = xbmcgui.Dialog()
dialog.notification('该功能未解锁','请先启用QQ音乐或者网易云的cookie功能', xbmcgui.NOTIFICATION_INFO, 5000)
@plugin.route('/mv/')
def mv():
items = []
items.append({
'label': '网易云 · MV',
'path': plugin.url_for('get_mv',mode='163',page=1),
})
items.append({
'label': 'QQ音乐 · MV',
'path': plugin.url_for('get_mv',mode='qq',page=1),
})
return items
@plugin.route('/so/')
def so():
items = []
items.append({
'label': '网易云 · 单曲搜索',
'path': plugin.url_for('history',name='搜索 网易云 · 单曲',url='search',mode='163',type='1')
})
items.append({
'label': 'QQ音乐 · 单曲搜索',
'path': plugin.url_for('history',name='搜索 QQ音乐 · 单曲',url='search',mode='qq',type='0')
})
items.append({
'label': '网易云 · 专辑搜索',
'path': plugin.url_for('history',name='搜索 网易云 · 专辑',url='search',mode='163',type='10')
})
items.append({
'label': 'QQ音乐 · 专辑搜索',
'path': plugin.url_for('history',name='搜索 QQ音乐 · 专辑',url='search',mode='qq',type='8')
})
items.append({
'label': '网易云 · 歌手搜索',
'path': plugin.url_for('history',name='搜索 网易云 · 歌手',url='search',mode='163',type='100')
})
items.append({
'label': 'QQ音乐 · 歌手搜索',
'path': plugin.url_for('history',name='搜索 QQ音乐 · 歌手',url='search',mode='qq',type='9')
})
items.append({
'label': '网易云 · 歌单搜索',
'path': plugin.url_for('history',name='搜索 网易云 · 歌单',url='search',mode='163',type='1000')
})
items.append({
'label': 'QQ音乐 · 歌单搜索',
'path': plugin.url_for('history',name='搜索 QQ音乐 · 歌单',url='search',mode='qq',type='2')
})
items.append({
'label': '网易云 · MV搜索',
'path': plugin.url_for('history',name='搜索 网易云 · MV',url='search',mode='163',type='1004')
})
items.append({
'label': 'QQ音乐 · MV搜索',
'path': plugin.url_for('history',name='搜索 QQ音乐 · MV',url='search',mode='qq',type='12')
})
# items.append({
# 'label': '网易云 · 电台搜索',
# 'path': plugin.url_for('history',name='搜索 网易云 · 电台',url='search',mode='163',type='1009')
# })
items.append({
'label': '网易云 · 视频搜索',
'path': plugin.url_for('history',name='搜索 网易云 · 视频',url='search',mode='163',type='1014')
})
# items.append({
# 'label': '复制粘贴歌单url解析歌单(支持网易云和QQ音乐)',
# 'path': plugin.url_for('get_mv',mode='163',page=1),
# })
# items.append({
# 'label': '复制粘贴MV url解析mv(支持网易云和QQ音乐)',
# 'path': plugin.url_for('get_mv',mode='163',page=1),
# })
return items
@plugin.route('/gedang/')
def gedang():
if xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusiccookieswitch') == 'true' or xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusiccookieswitch') == 'true':
items = []
if xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusicuid') != '' and xbmcplugin.getSetting(int(sys.argv[1]), 'neteasemusiccookieswitch') == 'true':
items.append({
'label': '网易云 · 我的歌单',
'path': plugin.url_for('get_gedang',mode='163'),
})
if xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusicid') != '' and xbmcplugin.getSetting(int(sys.argv[1]), 'qqmusiccookieswitch') == 'true':
items.append({
'label': 'QQ音乐 · 我的歌单',
'path': plugin.url_for('get_gedang',mode='qq'),
})
return items
else:
dialog = xbmcgui.Dialog()
dialog.notification('该功能未解锁','请先启用QQ音乐或者网易云的cookie功能', xbmcgui.NOTIFICATION_INFO, 5000)
@plugin.route('/rank/')
def rank():
gdlist = get_rank()
items = [{
'label': video['name'],
'path': plugin.url_for('ranklist',value=video['url'].encode('utf-8')),
'thumbnail': video['thumb'],
'icon': video['thumb'],
'info':{'plot':video['desc'],'mediatype':'video'},
'info_type':'video',
} for video in gdlist]
return items
@plugin.route('/ranklist//')
def ranklist(value):
# 通过传递 qq|排行榜id 或 163|排行榜id 的value值 来区分不同的排行榜
value = value.split("|")
if value[0] == '163':
gdlist = one63playlist(value[1])
if value[0] == 'qq':
gdlist = qqrank(value[1])
items = []
for video in gdlist:
try:
label = video['label']
except:
label = video['name']
items.append({
'label': label,
'path': video['url'],
'thumbnail': video['thumb'],
'icon': video['thumb'],
'is_playable': True,
'info':{'title':video['name'],'mediatype':'music'},
'info_type':'music',
} )
return items
@plugin.route('/get_mv///')
def get_mv(mode,page):
if mode == '163':
gdlist = one63mvlist(int(page))
else:
gdlist = qqmvlist(int(page))
items = [{
'label': video['name'],
'path': plugin.url_for('playmv',url=video['url']),
'thumbnail': video['thumb'],
'icon': video['thumb'],
} for video in gdlist]
if len(gdlist) == 50:
items.append({
'label': '下一页',
'path': plugin.url_for('get_mv',mode=mode,page=(int(page)+1)),
})
return items
@plugin.route('/get_tuijian//')
def get_tuijian(mode):
items = []
if mode == '163':
gdlist = one63tuijiangedan()
else:
gdlist = qqtuijiangedan()
for video in gdlist:
info = video['info']
info['mediatype'] = 'video'
items.append({
'label': video['name'],
'path': plugin.url_for('playlist',url=video['url']),
'thumbnail': video['thumb'],
'icon': video['thumb'],
'info':info,
'info_type':'video',
})
return items
@plugin.route('/get_ritui//')
def get_ritui(mode):
items = []
if mode == '163':
items.append({
'label':'每日推荐',
'thumbnail':'https://iph.href.lu/200x200?text='+time.strftime("%d", time.localtime()) +'&fg=FFFFFF&bg=FF0000',
'icon':'https://iph.href.lu/200x200?text='+time.strftime("%d", time.localtime()) +'&fg=FFFFFF&bg=FF0000',
'path': plugin.url_for('rituilist',mode='163'),
})
gdlist = one63weinituijian()
else:
items.append({
'label':'今日私享',
'thumbnail':'http://y.qq.com/m/resource/calendar/'+time.strftime("%m%d", time.localtime()) +'_300.jpg',
'icon':'http://y.qq.com/m/resource/calendar/'+time.strftime("%m%d", time.localtime()) +'_300.jpg',
'path': plugin.url_for('rituilist',mode='qq'),
})
gdlist = qqweinituijian()
for video in gdlist:
info = video['info']
info['mediatype'] = 'video'
items.append({
'label': video['name'],
'path': plugin.url_for('playlist',url=video['url']),
'thumbnail': video['thumb'],
'icon': video['thumb'],
'info':info,
'info_type':'video',
'context_menu':[('Theater Showtimes', 'RunScript(special://home/scripts/showtimes/default.py,Iron Man)')]
})
return items
@plugin.route('/rituilist//')
def rituilist(mode):
items = []
if mode == '163':
gdlist = one63ritui()
else:
gdlist = qqritui()
items = [{
'label': video['name'],
'path': video['url'],
'thumbnail': video['thumb'],
'icon': video['thumb'],
'is_playable': True,
'info':video['info'],
'info_type':'music',
} for video in gdlist]
return items
@plugin.route('/get_gedang//')
def get_gedang(mode):
items = []
if mode == '163':
gdlist = one63gedan()
else:
gdlist = qqgedan()
for video in gdlist:
info = video['info']
info['mediatype'] = 'video'
items.append({
'label': video['name'],
'path': plugin.url_for('playlist',url=video['url']),
'thumbnail': video['thumb'],
'icon': video['thumb'],
'info':info,
'info_type':'video',
})
return items
@plugin.route('/playlist//')
def playlist(url):
items = []
if 'playlist' in url:
dialog = xbmcgui.Dialog()
if '163.com' in url:
#网易云
if re.search('(?<=playlist\?id=)\d+',url):
pid = re.search('(?<=playlist\?id=)\d+',url).group()
gdlist = one63playlist(pid)
dialog.notification('提取网易云音乐歌单成功','歌单号:'+str(pid), xbmcgui.NOTIFICATION_INFO, 5000)
else:
if 'qq.com' in url:
#qq音乐
if re.search('(?<=playlist/)\d+',url):
pid = re.search('(?<=playlist/)\d+',url).group()
gdlist = qqplaylist(pid)
dialog.notification('提取QQ音乐歌单成功','歌单号:'+str(pid), xbmcgui.NOTIFICATION_INFO, 5000)
else:
#非法url
dialog = xbmcgui.Dialog()
ok = dialog.ok('错误提示', '无法识别的歌单url')
items = [{
'label': video['name'],
'path': video['url'],
'thumbnail': video['thumb'],
'icon': video['thumb'],
'is_playable': True,
'info':video['info'],
'info_type':'music',
} for video in gdlist]
return items
@plugin.route('/playmv//')
def playmv(url):
items = []
# dialog = xbmcgui.Dialog()
# ok = dialog.ok('错误提示', str(url))
if 'mv' in url:
if '163.com' in url:
#网易云
if re.search('(?<=mv\?id=)\d+',url):
vid = re.search('(?<=mv\?id=)\d+',url).group()
mp4url = one63playmv(vid)
mp4info = one63mvinfo(vid)
else:
if 'qq.com' in url:
#qq音乐
if re.search('(?<=mv/v/)[a-zA-Z0-9]+',url):
vid = re.search('(?<=mv/v/)[a-zA-Z0-9]+',url).group()
mp4url = qqplaymv(vid)
mp4info = qqmvinfo(vid)
#dialog = xbmcgui.Dialog()
#ok = dialog.ok('错误提示', vid)
mp4info['mediatype'] = 'video'
items.append({
'label': mp4info['title'],
'path': mp4url,
'thumbnail': mp4info['thumb'],
'icon': mp4info['thumb'],
'is_playable': True,
'info':mp4info,
'info_type':'video',
})
else:
#非法url
dialog = xbmcgui.Dialog()
ok = dialog.ok('错误提示', '无法识别的MVurl')
return items
@plugin.route('/playvideo//')
def playvideo(url):
items = []
# dialog = xbmcgui.Dialog()
# ok = dialog.ok('错误提示', str(url))
if 'video' in url and '163.com' in url:
#网易云
if re.search('(?<=video\?id=)[a-zA-Z0-9]+',url):
vid = re.search('(?<=video\?id=)[a-zA-Z0-9]+',url).group()
mp4url = one63playvideo(vid)
mp4info = one63videoinfo(vid)
#dialog = xbmcgui.Dialog()
#ok = dialog.ok('错误提示', vid)
mp4info['mediatype'] = 'video'
items.append({
'label': mp4info['title'],
'path': mp4url,
'thumbnail': mp4info['thumb'],
'icon': mp4info['thumb'],
'is_playable': True,
'info':mp4info,
'info_type':'video',
})
else:
#非法url
dialog = xbmcgui.Dialog()
ok = dialog.ok('错误提示', '无法识别的视频url')
return items
@plugin.route('/playalbum//')
def playalbum(url):
items = []
if 'album' in url:
if '163.com' in url:
#网易云
if re.search('(?<=album\?id=)\d+',url):
pid = re.search('(?<=album\?id=)\d+',url).group()
gdlist = one63album(pid)
else:
if 'qq.com' in url:
#qq音乐
if re.search('(?<=album/)[a-zA-Z0-9]+',url):
pid = re.search('(?<=album/)[a-zA-Z0-9]+',url).group()
gdlist = qqalbum(pid)
# dialog = xbmcgui.Dialog()
# ok = dialog.ok('错误提示', pid)
else:
#非法url
dialog = xbmcgui.Dialog()
ok = dialog.ok('错误提示', '无法识别的专辑url')
items = [{
'label': video['name'],
'path': video['url'],
'thumbnail': video['thumb'],
'icon': video['thumb'],
'is_playable': True,
'info':{'title':video['name'],'mediatype':'album'},
'info_type':'music',
} for video in gdlist]
return items
@plugin.route('/playsinger//')
def playsinger(url):
items = []
if 'artist' in url or 'singer' in url:
if '163.com' in url:
#网易云
if re.search('(?<=artist\?id=)\d+',url):
pid = re.search('(?<=artist\?id=)\d+',url).group()
gdlist = one63singer(pid)
else:
if 'qq.com' in url:
#qq音乐
if re.search('(?<=singer/)[a-zA-Z0-9]+',url):
pid = re.search('(?<=singer/)[a-zA-Z0-9]+',url).group()
gdlist = qqsinger(pid)
# dialog = xbmcgui.Dialog()
# ok = dialog.ok('错误提示', pid)
else:
#非法url
dialog = xbmcgui.Dialog()
ok = dialog.ok('错误提示', '无法识别的歌手url')
items = [{
'label': video['name'],
'path': video['url'],
'thumbnail': video['thumb'],
'icon': video['thumb'],
'is_playable': True,
'info':{'title':video['name'],'mediatype':'album'},
'info_type':'music',
} for video in gdlist]
return items
@plugin.route('/labels/