Giter VIP home page Giter VIP logo

bgmi's Introduction

BGmi

BGmi 是一个用来追番的命令行程序.

test

TODO

更新日志

v4

  • 命令自动补全,使用 bgmi completion zsh/bash 生成
  • 添加 mikan_url 配置,用于配置蜜柑计划镜像站。
  • 添加 proxy 设置
  • 新 WEB UI
  • 将配置项 transmission.rpc_url 重命名为 transmission.rpc_host.
  • 修复 Transmission 配置的默认值.

v3

  • 新增配置项 global_include_keywords ,用于设置全局包含关键词。
  • 新增配置项 save_path_map ,用于设置不同动画的下载路径。
  • 使用 TOML 作为配置文件
  • 不再支持 python3.7
  • 不再支持 python3.6
  • 支持扩展下载方式
  • 移除迅雷离线
  • 支持 qbittorrent-webapi
  • 停止支持 python2,3.4 和 3.5
  • Transmission rpc 认证设置
  • 支持 deluge-rpc
  • 使用最大和最小集数筛选搜索结果

特性

  • 多个数据源可选: bangumi_moe, mikan_project 或者dmhy
  • 使用 aria2, transmission, qbittorrent 或者 deluge 来下载你的番剧.
  • 提供一个管理和观看订阅番剧的前端.
  • 弹幕支持
  • 提供 uTorrent 支持的 RSS Feed 和移动设备支持的 ICS 格式日历.
  • Bangumi Script: 添加自己的番剧解析器
  • 番剧放松列表和剧集信息
  • 下载番剧时的过滤器(支持关键词,字幕组和正则)
  • 多平台支持: Windows, *nux 以及 Router system

安装

使用 pipx 安装(推荐):

pipx install bgmi

使用 pip 安装稳定版本:

pip install bgmi

或者从源码安装(不推荐)

git clone https://github.com/BGmi/BGmi
cd BGmi
git checkout master
python -m pip install -U pip
pip install .

初始化BGmi

bgmi install

升级(仅 pipx 安装)

pipx upgrade bgmi
bgmi upgrade

升级(仅 pip 安装)

pip install bgmi -U
bgmi upgrade

在升级后请确保运行bgmi upgrade

使用 Docker

BGmi/bgmi-docker-all-in-one

使用

查看可用的命令

bgmi --help

--help选项同样适用于所有的子命令,readme 仅介绍了一些基础用法。

命令自动补全

bash

bgmi completion bash > ~/.bash_completion.d/bgmi

zsh

oh-my-zsh

bgmi completion zsh > .oh-my-zsh/completions/_bgmi

我不使用其他的 zsh 插件管理器,具体的安装方法请查询你使用的插件管理器文档

配置 BGmi

BGmi 提供两种方式配置BGmi的各项运行参数,分别为配置文件与环境变量。

配置文件

bgmi 的配置文件位于 ${BGMI_PATH}/config.toml, 在未设置 BGMI_PATH 环境变量时,${BGMI_PATH} 默认为 ~/.bgmi/

查看当前 BGmi 设置:

bgmi config # 查看当前各项设置默认值.
data_source = "bangumi_moe" # bangumi source,!!! 请不要手动修改此选项 !!!
download_delegate = "aria2-rpc" # 番剧下载工具 (aria2-rpc, transmission-rpc, deluge-rpc, qbittorrent-webapi)
tmp_path = "tmp/tmp" # tmp dir
save_path = "tmp/bangumi" # 下载番剧保存地址
max_path = 3 # 抓取数据时每个番剧最大抓取页数
bangumi_moe_url = "https://bangumi.moe"
share_dmhy_url = "https://share.dmhy.org"
mikan_url = "https://mikanani.me"
mikan_username = "" # 蜜柑计划的用户名
mikan_password = "" # 蜜柑计划的密码
enable_global_filters = true
global_filters = [
    "Leopard-Raws",
    "hevc",
    "x265",
    "c-a Raws",
    "U3-Web",
]

proxy = '' # http proxy example: http://127.0.0.1:1080

[save_path_map] # 针对每部番剧设置下载路径
'致不灭的你 第二季' = '/home/trim21/downloads/bangumi/致不灭的你/s2/' # 如果使用绝对路径,可能导致 web-ui 无法正确显示视频文件。
'致不灭的你 第三季' = './致不灭的你/s3/' # 以 save_path 为基础路径的相对路径

[http]
admin_token = "dYMj-Z4bDRoQfd3x" # web ui 的密码
danmaku_api_url = ""
serve_static_files = false

[aria2]
rpc_url = "http://localhost:6800/rpc" # aria2c RPC URL (不是 jsonrpc URL, 如果你的 aria2c 运行在 localhost:6800, 对应的链接为 `http://localhost:6800/rpc`)
rpc_token = "token:" # aria2c RPC token (如果没有设置 token, 留空或者设置为 `token:`)

[transmission]
rpc_host = "127.0.0.1"
rpc_port = 9091
rpc_username = "your_username"
rpc_password = "your_password"
rpc_path = "/transmission/rpc" # transmission http rpc 的请求路径

[qbittorrent]
rpc_host = "127.0.0.1"
rpc_port = 8080
rpc_username = "admin"
rpc_password = "adminadmin"
category = ""

[deluge]
rpc_url = "http://127.0.0.1:8112/json"
rpc_password = "deluge"

环境变量

当 BGmi 的配置文件还未初始化时,各项运行参数可由环境变量进行配置

环境变量以 BGMI_ 开头,全大写命名,且各级配置以 _ 进行分割,如:

BGMI_DATA_SOURCE=bangumi_moe    # 对应配置文件中的 data_source = "bangumi_moe"
BGMI_HTTP_ADMIN_TOKEN=dYMj-Z4bDRoQfd3x    # 对应配置文件 [http] 分段中的 admin_token = "dYMj-Z4bDRoQfd3x"
...

环境变量 暂不支持 配置以下项目

enable_global_include_keywords
enable_global_filters
global_include_keywords
global_filters
[save_path_map]

注: 当配置文件生成完毕后,运行配置将会以配置文件为准,环境变量仅用于生成第一份配置文件。

修改配置

使用 bgmi config set ...keys --value '...' 命令可以修改配置。

如:

bgmi config set http admin_token --value 'my super secret token'

或者

bgmi config set max_path --value '3'

不能用来修改复杂配置,如 global_filters,请手动修改配置文件。

支持的数据源

更换换数据源

更换数据源会清空番剧数据库, 但是 bgmi script 不受影响. 之前下载的视频文件不会删除, 但是不会在前端显示

如果更换的源为 mikan_project, 请先配置 MIKAN_USERNAMEMIKAN_PASSWORD, 其它源不受影响

bgmi source mikan_project

切换数据源必需使用bgmi source命令,不能手动修改配置文件。手动修改配置文件会导致 bgmi 报错

设置下载方式

修改配置文件和对应的配置项

download_delegate = "aria2-rpc" # download delegate

内置可用的选项包括 aria2-rpc, transmission-rpc, qbittorrent-webapi 以及 deluge-rpc

查看目前正在更新的新番

bgmi cal

订阅番剧:

bgmi add "进击的巨人 第三季" "刃牙" "哆啦A梦"
bgmi add "高分少女" --episode 0

添加番剧的同时设置下载路径:

bgmi add "高分少女" --episode 0 --save-path './高分少女/S1/'

退订:

bgmi delete "Re:CREATORS"

更新番剧列表并且下载番剧:

bgmi update --download # update all
bgmi update "从零开始的魔法书" --download

设置筛选条件:

bgmi list # 列出目前订阅的番剧
bgmi fetch "Re:CREATORS"
# include和exclude会忽略大小写。`720p`和`720P`的效果是相同的
bgmi filter "Re:CREATORS" --subtitle "DHR動研字幕組,豌豆字幕组" --include 720P --exclude BIG5
bgmi fetch "Re:CREATORS"
# 删除subtitle,include和exclude,添加正则匹配
bgmi filter "Re:CREATORS" --subtitle "" --include "" --exclude "" --regex "..."
bgmi filter "Re:CREATORS" --regex "(DHR動研字幕組|豌豆字幕组).*(720P)"
bgmi fetch "Re:CREATORS"

设置全局过滤关键词

包含

默认不启用全局包含关键词,你可以设置 enable_global_include_keywords = true 启动此功能。

enable_global_include_keywords = true
global_include_keywords = ['1080']

排除

有一些默认定义的全局过滤关键词,默认会排除标题包含以下关键词的种子。 可以使用 enable_global_filters = false 禁止过滤全局关键词,

enable_global_filters = true
global_filters = [
  "Leopard-Raws",
  "hevc",
  "x265",
  "c-a Raws",
  "U3-Web",
]

最后使用bgmi fetch来看看筛选的结果.

搜索番剧并下载:

bgmi search '为美好的世界献上祝福!' --regex-filter '.*动漫国字幕组.*为美好的世界献上祝福!].*720P.*'

使用--min-episode--max-episode来根据集数筛选下载结果

bgmi search 海贼王 --min-episode 800 --max-episode 820
# 下载
bgmi search 海贼王 --min-episode 800 --max-episode 820 --download

bgmi search命令默认不会显示重复的集数, 如果要显示重复的集数来方便过滤, 在命令后加上--dupe来显示全部的搜索结果

手动修改最近下载的剧集

bgmi list
bgmi mark "Re:CREATORS" 1

使用bgmi_http

1.先下载所有更新中番剧的封面

bgmi cal --download-cover

2.根据你是否使用 nginx, 设置serve_static_files(使用 nginx 的情况下使用默认设置false, 不使用的情况下设置为true)

3.下载前端的静态文件(你可能在安装的时候已经下载过了):

bgmi install

4.在8888端口启动 BGmi HTTP 服务器:

bgmi_http --port=8888 --address=0.0.0.0

在 Windows 上使用bgmi_http

参照上面启动服务器, 然后访问http://localhost:8888/.

在*nux 上使用 bgmi_http

可以让BGmi帮助你生成对应的 nginx 配置文件

bgmi gen nginx.conf --server-name bgmi.whatever.com

你也可以手动写一份 nginx 配置, 来满足你的更多需求(比如启用 https), 这是一份例子

server {
    listen 80;
    server_name bgmi;

    autoindex on;
    charset utf-8;

    location /bangumi {
        # ~/.bgmi/bangumi
        # alias到你的`SAVE_PATH` 注意以/结尾
        alias /path/to/bangumi/;
    }

    location /api {
        proxy_pass http://127.0.0.1:8888;
    }

    location /resource {
        proxy_pass http://127.0.0.1:8888;
    }

    location / {
        # alias到你的`BGMI_PATH/front_static/`注意以/结尾
        alias /path/to/front_static/;
    }
}

或者添加一个 aria2c 前端之类的, 具体办法百度上有很多,不在此赘述.

macOS launchctl service controller

参照 issue #77自行设置

me.ricterz.bgmi.plist

弹幕支持

BGmi 使用DPlayer做为前端播放器

如果你想要添加弹幕支持, 在这里DPlayer#related-projects选择一个后端自行搭建, 或者使用DPlayer提供的现成接口https://api.prprpr.me/dplayer/

然后修改配置文件:

[bgmi_http]
danmaku_api_url = "https://api.prprpr.me/dplayer/"  # This api is provided by dplayer official

设置你的bgmi_http, 享受弹幕支援吧.

调试

log 文件位于{BGMI_PATH}/tmp/

卸载

由于 pip 的限制, 你需要手动清理BGmi产生的位于~/.bgmi的文件

同样, BMmi添加到你系统的定时任务也不会被自动删除, 请手动删除.

*nix:

请手动清理crontab

windows:

schtasks /Delete /TN 'bgmi updater'

如果你对 python 有一点了解, 并且觉得还不够的话, 下面是为你准备的.

Bangumi Script

你可以写一个BGmi Script来解析你自己的想看的番剧或者美剧. BGmi 会加载你的 script, 视作一个番剧来对待. 而你所需要做的只是继承ScriptBase类, 然后实现特定的方法, 再把你的 script 文件放到BGMI_PATH/script文件夹内.

Example: ./tests/script_example.py

get_download_url()返回一个dict, 以对应集数为键, 对应的下载链接为值

{
    1: 'http://example.com/Bangumi/1/1.mp4',
    2: 'http://example.com/Bangumi/1/2.torrent',
    3: 'http://example.com/Bangumi/1/3.mp4'
}

Download hook

你可以在下载完成前或下载完成后执行一些操作, 比如移动文件, 重命名文件等等. 将你的 hook 文件放到BGMI_PATH/hooks文件夹内即可.

from loguru import logger
from bgmi.script import HookBase


# 只需要继承 HookBase 类,实现里面的方法即可,类名字可任意设置
class Hook(HookBase):
    # 在添加了下载任务之后执行
    def post_add_download(self) -> None:
        logger.info('post add download')

    # 在更新了状态,下载之前进行执行
    def pre_add_download(self) -> None:
        logger.info('pre add download')

BGmi 数据源

通过扩展bgmi.website.base.BaseWebsite类并且实现对应的三个方法,你也可以简单的添加一个数据源

每个方法具体的意义和返回值格式请参照每个方法对应的注释

from typing import List, Optional

from bgmi.website.base import BaseWebsite
from bgmi.website.model import Episode, WebsiteBangumi


class DataSource(BaseWebsite):
    def search_by_keyword(
        self, keyword: str, count: int
    ) -> List[Episode]:  # pragma: no cover
        """

        :param keyword: search key word
        :param count: how many page to fetch from website
        :return: list of episode search result
        """
        raise NotImplementedError

    def fetch_bangumi_calendar(self,) -> List[WebsiteBangumi]:  # pragma: no cover
        """
        return a list of all bangumi and a list of all subtitle group

        list of bangumi dict:
        update time should be one of ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Unknown']
        """
        raise NotImplementedError

    def fetch_episode_of_bangumi(
        self, bangumi_id: str, max_page: int, subtitle_list: Optional[List[str]] = None
    ) -> List[Episode]:  # pragma: no cover
        """
        get all episode by bangumi id

        :param bangumi_id: bangumi_id
        :param subtitle_list: list of subtitle group
        :type subtitle_list: list
        :param max_page: how many page you want to crawl if there is no subtitle list
        :type max_page: int
        :return: list of bangumi
        """
        raise NotImplementedError


    def fetch_single_bangumi(self, bangumi_id: str) -> WebsiteBangumi:
        """
        fetch bangumi info when updating

        :param bangumi_id: bangumi_id, or bangumi['keyword']
        :type bangumi_id: str
        :rtype: WebsiteBangumi
        """
        # return WebsiteBangumi(keyword=bangumi_id) if website don't has a page contains episodes and info

License

MIT License

bgmi's People

Contributors

chinuno-usami avatar codysk avatar ddsderek avatar deepsource-autofix[bot] avatar ihciah avatar kaaass avatar kahosan avatar liznzn avatar messyidea avatar mnixry avatar renovate-bot avatar renovate[bot] avatar ricterz avatar sg4dylan avatar shincurry avatar superfashi avatar tinkoliu avatar trim21 avatar zeyugao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bgmi's Issues

api/index里包括了未下载完的剧集

aria2c下载文件的时候如果没有下载完成不会添加一个.part之类的后缀名,然后会被认为下载完了...但是实际上放不了(
其他下载工具不知道有没有同样的问题

一个很迷醉的bug........

..http.py跟http标准库重名了...
一直以来我的torando都不能autoreload,终于发现是为什么了...

bgmi.lib.models.FollowedDoesNotExist: <class 'bgmi.lib.models.Followed'> when running bgmi fetch

Platform:
Ubuntu 16.04

python version:
Python 2.7.12

BGmi version:
ver. 2.0.5

bgmi fetch "刀剑神域外传 Gun Gale Online"
Traceback (most recent call last):
  File "/usr/local/bin/bgmi", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/bgmi/main.py", line 63, in main
    controllers(ret)
  File "/usr/local/lib/python2.7/dist-packages/bgmi/lib/cli.py", line 324, in controllers
    return func(ret)
  File "/usr/local/lib/python2.7/dist-packages/bgmi/lib/cli.py", line 209, in fetch_
    Followed.get(bangumi_name=bangumi_obj.name)
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 5175, in get
    return sq.get()
  File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 5563, in get
    (clone.model, sql, params))
bgmi.lib.models.FollowedDoesNotExist: <class 'bgmi.lib.models.Followed'> instance matching query does not exist:
SQL: SELECT "t1"."id", "t1"."bangumi_name", "t1"."episode", "t1"."status", "t1"."updated_time" FROM "followed" AS "t1" WHERE ("t1"."bangumi_name" = ?) LIMIT 1 OFFSET 0

尝试过删掉 bangumi.db 重新 update 、换源现象依旧

sre_constants.error

Platform:
windows 10 x64 1709
python version:
python 3.6.5
BGmi version:
BGmi 2.0.6

问题:
Traceback (most recent call last):
File "D:\Python36\Scripts\bgmi-script.py", line 11, in
load_entry_point('bgmi==2.0.6', 'console_scripts', 'bgmi')()
File "d:\python36\lib\site-packages\bgmi\main.py", line 66, in main
controllers(ret)
File "d:\python36\lib\site-packages\bgmi\lib\cli.py", line 340, in controllers
return func(ret)
File "d:\python36\lib\site-packages\bgmi\lib\cli.py", line 48, in search_wrapper
download_prepare(data)
File "d:\python36\lib\site-packages\bgmi\lib\download.py", line 50, in download_prepare
if not glob.glob(save_path):
File "d:\python36\lib\glob.py", line 20, in glob
return list(iglob(pathname, recursive=recursive))
File "d:\python36\lib\glob.py", line 71, in _iglob
for dirname in dirs:
File "d:\python36\lib\glob.py", line 72, in _iglob
for name in glob_in_dir(dirname, basename, dironly):
File "d:\python36\lib\glob.py", line 83, in _glob1
return fnmatch.filter(names, pattern)
File "d:\python36\lib\fnmatch.py", line 52, in filter
match = _compile_pattern(pat)
File "d:\python36\lib\fnmatch.py", line 46, in _compile_pattern
return re.compile(res).match
File "d:\python36\lib\re.py", line 233, in compile
return _compile(pattern, flags)
File "d:\python36\lib\re.py", line 301, in _compile
p = sre_compile.compile(pattern, flags)
File "d:\python36\lib\sre_compile.py", line 562, in compile
p = sre_parse.parse(p, flags)
File "d:\python36\lib\sre_parse.py", line 855, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "d:\python36\lib\sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "d:\python36\lib\sre_parse.py", line 765, in _parse
p = _parse_sub(source, state, sub_verbose, nested + 1)
File "d:\python36\lib\sre_parse.py", line 416, in _parse_sub
not nested and not items))
File "d:\python36\lib\sre_parse.py", line 553, in _parse
raise source.error(msg, len(this) + 1 + len(that))
sre_constants.error: bad character range 域-1 at position 6

尝试下载其他番剧没有出现问题,应该是我所下载的番剧的名称的问题,不知怎样解决。
出问题番剧为:[异域-11番小队][在地下城寻求邂逅是否搞错了什么 Danmachi][01-13][BDRIP][720P][X264-10bit_AAC]

蜜柑计划季节番组表支持

Platform:
Arch Linux ARM
python version:
Python 3.6.5
BGmi version:
BGmi ver. 2.0.6 dev branch

问题:
订阅源为蜜柑计划时,前一季没放送完的动画消失了(比如 DitF 还有一集,Calendar 里缺已经康不到了)。
Calendar
大概是因为蜜柑计划换季会切换番组表吧(DitF 是春季番组的)
番组表切换
这个版本前端没有 Old bangumi 的入口,
所以这些没有完结的只能在 Bangumi Files 康了么?
以及它们还会继续更新么?
Menu?

New download delegate : Deluge

Transmission在windows下有些问题...(比如daemon必须要用任务管理器才能关闭
最近一直在用Deluge,添加了一个下载方式,现在人肉测试中,一个星期之内要是没出什么bug就合并到dev分支去

usage:

在deluge中启用webui
DOWNLOAD_DELEGATE设置为deluge-rpc
如果有必要的话,修改DELUGE_RPC_URLDELUGE_RPC_PASSWORD

(webui的默认密码是deluge

bgmi cal: IOError

ricter@baka:/tmp/BGmi$ bgmi cal
Traceback (most recent call last):
  File "/usr/local/bin/bgmi", line 9, in <module>
    load_entry_point('bgmi==1.4.6', 'console_scripts', 'bgmi')()
  File "/usr/local/lib/python2.7/dist-packages/bgmi-1.4.6-py2.7.egg/bgmi/main.py", line 183, in setup
    main()
  File "/usr/local/lib/python2.7/dist-packages/bgmi-1.4.6-py2.7.egg/bgmi/main.py", line 144, in main
    check_update()
  File "/usr/local/lib/python2.7/dist-packages/bgmi-1.4.6-py2.7.egg/bgmi/utils/utils.py", line 195, in check_update
    with open(os.path.join(BGMI_ADMIN_PATH, 'package.json'), 'r') as f:
IOError: [Errno 2] No such file or directory: u'/home/ricter/.bgmi/admin/package.json'

Mikan数据源抓取异常

Platform:
CentOS 7
python version:
3.4.5
BGmi version:
2.0.5 by pip3

所有来自mikan源的番剧,字幕组信息全部紊乱无法使用

#bgmi filter '刀剑神域 Alternative GGO'
[*] Usable subtitle group: 异域字幕组, 雪飘工作室, 红烧鱼字幕组
#bgmi filter '我的英雄学院 第三季' --subtitle "八重樱字幕组,波洛咖啡厅字幕组,YMDR发布组"
[*] Usable subtitle group: 异域字幕组, 雪飘工作室, 红烧鱼字幕组
#bgmi filter 'DARLING in the FRANXX'
[*] Usable subtitle group: OPFans枫雪动漫, Dymy字幕组, 异域字幕组, 雪飘工作室, 红烧鱼字幕组
"name": "名侦探柯南",
    "followed": [],
    "subtitle_group": [
      "OPFans枫雪动漫",
      "Dymy字幕组",
      "异域字幕组",
      "雪飘工作室",
      "红烧鱼字幕组",
      "紫音字幕组",
      "天空树双语字幕组"
    ]
"name": "DARLING in the FRANXX",
    "followed": [],
    "subtitle_group": [
      "OPFans枫雪动漫",
      "Dymy字幕组",
      "异域字幕组",
      "雪飘工作室",
      "红烧鱼字幕组",
      "紫音字幕组"
    ]
 "name": "魔卡少女樱 CLEAR CARD篇",
    "followed": [],
    "subtitle_group": [
      "OPFans枫雪动漫",
      "Dymy字幕组",
      "异域字幕组",
      "雪飘工作室",
      "红烧鱼字幕组",
      "紫音字幕组",
      "天空树双语字幕组"
    ]

關於webm視頻格式的支持

http api不會返回webm格式的視頻呢
webm的話現在的瀏覽器的播放支持應該已經挺不錯了 能不能考慮加上對應的支持呢

不能直接用update_time做为默认的sort key..

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/tornado/web.py", line 1509, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "/usr/local/lib/python3.4/dist-packages/bgmi-1.4.6-py3.4.egg/bgmi/front/http.py", line 223, in get
    data.sort(key=lambda _: _['updated_time'])
TypeError: unorderable types: NoneType() < int()

添加了之后没update过的话会这样...
看了眼数据库,是因为update_time是空的....

Docker

有什么 Docker image 的想法吗..
Docker 现在 aria2 下载不动..

print_* indicator

^^/W/G/BGmi >>> bgmi config                                                                                                                                 (*dev+702) 09:46:47
[*] [bgmi]
BANGUMI_MOE_URL=https://bangumi.moe
SAVE_PATH=/Users/ricterz/.bgmi/bangumi
DOWNLOAD_DELEGATE=aria2-rpc
MAX_PAGE=3
DATA_SOURCE=bangumi_moe
TMP_PATH=/Users/ricterz/.bgmi/tmp
DANMAKU_API_URL=233
LANG=zh_cn
ADMIN_TOKEN=488dce35780551292258188f04856ab6

[aria2-rpc]
ARIA2_RPC_URL=http://127.0.0.1:6800/rpc
ARIA2_RPC_TOKEN=token:

这里应该没有[*]

Can not find a way to modify this

BGmi HTTP Service

Please modify your web server configure file
to server this path to '/Users/xxx/.bgmi/bangumi'.
e.g.

...
autoindex on;
location /bangumi {
alias /Users/xxx/.bgmi/bangumi;
}
...

Cron task failure

Python 3.6.4
OSX 10.11.6
手动执行任务时正常
zsh、bash均能正常执行命令
执行Cron定时任务时发生如下错误

Sun Jan 28 10:00:46 2018
Received: by  (Postfix, from userid 501)
	 Sun, 28 Jan 2018 10:00:46 +0800 (CST)
From:  (Cron Daemon)
Subject: Cron <[user_name]]@[host_name]> /usr/local/bin/bgmi cal --force-update --download-cover
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=[user_name]]>
X-Cron-Env: <USER=[user_name]]>
X-Cron-Env: <HOME=/Users/[user_name]]>
Message-Id: <20180128020046.5637E143F46D@[host_name].local>
Date: Sun, 28 Jan 2018 10:00:01 +0800 (CST)

[*] Fetching bangumi info ...
Traceback (most recent call last):
  File "/usr/local/bin/bgmi", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/bgmi/main.py", line 58, in main
    controllers(ret)
  File "/usr/local/lib/python3.6/site-packages/bgmi/cli.py", line 290, in controllers
    return func(ret)
  File "/usr/local/lib/python3.6/site-packages/bgmi/cli.py", line 101, in cal_wrapper
    env_columns = 42 if os.environ.get('TRAVIS_CI', False) else get_terminal_col()
  File "/usr/local/lib/python3.6/site-packages/bgmi/utils/utils.py", line 172, in get_terminal_col
    struct.pack(str('HHHH'), 0, 0, 0, 0)))
OSError: [Errno 25] Inappropriate ioctl for device

From [user_name]]@[host_name].local  Sun Jan 28 12:00:47 2018
Return-Path: <[user_name]]@[host_name].local>
X-Original-To: [user_name]]
Delivered-To: [user_name]]@[host_name].local
Received: by [host_name].local (Postfix, from userid 501)
	id 2965F1441660; Sun, 28 Jan 2018 12:00:47 +0800 (CST)
From: [user_name]]@[host_name].local (Cron Daemon)
To: [user_name]]@[host_name].local
Subject: Cron <[user_name]]@[host_name]> /usr/local/bin/bgmi update --download
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=[user_name]]>
X-Cron-Env: <USER=[user_name]]>
X-Cron-Env: <HOME=/Users/[user_name]]>
Message-Id: <20180128040047.2965F1441660@[host_name].local>
Date: Sun, 28 Jan 2018 12:00:00 +0800 (CST)

[*] marking bangumi status ...
[*] updating bangumi data ...
[*] updating subscriptions ...
Traceback (most recent call last):
  File "/usr/local/bin/bgmi", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.6/site-packages/bgmi/main.py", line 58, in main
    controllers(ret)
  File "/usr/local/lib/python3.6/site-packages/bgmi/cli.py", line 290, in controllers
    return func(ret)
  File "/usr/local/lib/python3.6/site-packages/bgmi/cli.py", line 171, in update_wrapper
    update(name=ret.name, download=ret.download, not_ignore=ret.not_ignore)
  File "/usr/local/lib/python3.6/site-packages/bgmi/controllers.py", line 303, in update
    print_info('fetching %s ...' % subscribe['bangumi_name'])
  File "/usr/local/lib/python3.6/site-packages/bgmi/utils/utils.py", line 95, in wrapper
    f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/bgmi/utils/utils.py", line 110, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/bgmi/utils/utils.py", line 118, in print_info
    print(message)
  File "/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/codecs.py", line 376, in write
    data, consumed = self.encode(object, self.errors)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 13-17: ordinal not in range(128)

bugs

  • travis测试用例太老
  • 刚换季的时候不是一周内每天都有番剧,单元测试中的逻辑有问题
  • 要追ova...

对番剧名称内有 "/" 字符的会生成出错误的下载路径

Platform: Ubuntu16.04

python version: 2.7.12

BGmi version: 2.0.5

├── DARLING in the FRANXX
│   ├── 13 #正常的下载路径
│   │   ├── [DARLING in the FRANXX][13][GB][1080P].mp4
│   │   ├── download.1.torrent
│   │   └── download.torrent
├── Fate
│   └── EXTRA Last Encore
│       ├── 10 #名字里带/的下载路径,"Fate/EXTRA"被解析成了两级目录
│       │   └── [JYFanSub][Fate Extra Last Encore][10][720P][BIG5].mp4

疑似直接拼字符串导致的,或许应该对这个输入做一下转义或者序列化?

transmission-rpc的下载代理在python3下运行报错

Platform:
docker alpinelinux 3.7
python version:
3.6
BGmi version:
2.0.5

bash-4.4# DEBUG=1 bgmi update --download
。。。。
https://bangumi.moe/download/torrent/5aafdc0eaee915a509e18d95/download.torrent
https://bangumi.moe/download/torrent/5aafdc04aee915a509e18d93/download.torrent
[+] DARLING in the FRANXX updated, episode: 12
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/bgmi/lib/download.py", line 58, in download_prepare
    download_class.download()
  File "/usr/lib/python3.6/site-packages/bgmi/downloader/transmission_rpc.py", line 88, in download
    tc.add_torrent(self.torrent, download_dir=self.save_path.encode('utf-8'))
  File "/usr/lib/python3.6/site-packages/bgmi/downloader/transmission_rpc.py", line 31, in add_torrent
    opener = urllib.build_opener()
AttributeError: module 'urllib' has no attribute 'build_opener'
Traceback (most recent call last):
  File "/usr/bin/bgmi", line 11, in <module>
    load_entry_point('bgmi==2.0.5', 'console_scripts', 'bgmi')()
  File "/usr/lib/python3.6/site-packages/bgmi/main.py", line 63, in main
    controllers(ret)
  File "/usr/lib/python3.6/site-packages/bgmi/lib/cli.py", line 324, in controllers
    return func(ret)
  File "/usr/lib/python3.6/site-packages/bgmi/lib/cli.py", line 175, in update_wrapper
    update(name=ret.name, download=ret.download, not_ignore=ret.not_ignore)
  File "/usr/lib/python3.6/site-packages/bgmi/lib/controllers.py", line 340, in update
    download_prepare(download_queue)
  File "/usr/lib/python3.6/site-packages/bgmi/lib/download.py", line 67, in download_prepare
    raise e
  File "/usr/lib/python3.6/site-packages/bgmi/lib/download.py", line 58, in download_prepare
    download_class.download()
  File "/usr/lib/python3.6/site-packages/bgmi/downloader/transmission_rpc.py", line 88, in download
    tc.add_torrent(self.torrent, download_dir=self.save_path.encode('utf-8'))
  File "/usr/lib/python3.6/site-packages/bgmi/downloader/transmission_rpc.py", line 31, in add_torrent
    opener = urllib.build_opener()
AttributeError: module 'urllib' has no attribute 'build_opener'

看起来在python3里build_opener应该是在urllib.request.build_opener这个位置的

peewee.IntegrityError: UNIQUE constraint failed: subtitle.id

[-] Warning: no bangumi schedule, fetching ...
Traceback (most recent call last):
  File "/usr/local/bin/bgmi", line 9, in <module>
    load_entry_point('bgmi==2.0.5', 'console_scripts', 'bgmi')()
  File "/usr/local/lib/python2.7/dist-packages/bgmi-2.0.5-py2.7.egg/bgmi/main.py", line 63, in main
    controllers(ret)
  File "/usr/local/lib/python2.7/dist-packages/bgmi-2.0.5-py2.7.egg/bgmi/lib/cli.py", line 324, in controllers
    return func(ret)
  File "/usr/local/lib/python2.7/dist-packages/bgmi-2.0.5-py2.7.egg/bgmi/lib/cli.py", line 86, in cal_wrapper
    force_update=force_update, save=save, cover=cover)
  File "/usr/local/lib/python2.7/dist-packages/bgmi-2.0.5-py2.7.egg/bgmi/website/base.py", line 110, in bangumi_calendar
    weekly_list = self.fetch(save=save)
  File "/usr/local/lib/python2.7/dist-packages/bgmi-2.0.5-py2.7.egg/bgmi/website/base.py", line 47, in fetch
    name=_unicode(subtitle_group['name']))
  File "/usr/local/lib/python2.7/dist-packages/peewee-3.1.5-py2.7.egg/peewee.py", line 5195, in get_or_create
    raise exc
peewee.IntegrityError: UNIQUE constraint failed: subtitle.id

今天打开突然挂了..

bgmi_http cover AttributeError: 'NoneType' object has no attribute 'replace'

http://bgmi.ricterz.me/player/Rick%20and%20Morty%20Season%203/#episode_8

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1509, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/bgmi-1.4.6-py2.7.egg/bgmi/front/http.py", line 141, in get
    bangumi_cover='{}/{}'.format(COVER_URL, normalize_path(bangumi_obj['cover'])),
  File "/usr/local/lib/python2.7/dist-packages/bgmi-1.4.6-py2.7.egg/bgmi/utils/utils.py", line 263, in normalize_path
    url = url.replace('http://', 'http/').replace('https://', 'https/')
AttributeError: 'NoneType' object has no attribute 'replace'

使用蜜柑计划作为数据源时的问题

Platform:
Arch Linux ARM
python version:
Python 3.6.4
BGmi version:
BGmi ver. 2.0.5 from PyPi & Git

问题 A.0: 订阅页面 DETAIL 无法正确显示字幕组列表
如图: bug?
看上去和 #85 是同一个问题,换到 dev 分支即可

问题 A.1:
dev 分支上订阅页面不正常显示 DETAIL,按下 ADD 后提示已订阅
(数据库里的订阅数据是正常的,但是前端显示异常的样子)
如图: bug!

问题 B: crontab 计划任务执行失败后丢失订阅
出现问题后敲 bgmi cal 往往就能解决,但是似乎问题出现频率挺高的

Http API to get mark of bangumi

直接加在controller上的话大概会改变cli里mark的行为...
不过仔细一想本来bgmi mark bangumi_name就该返回现在的mark....(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.