Giter Club home page Giter Club logo

albireo's Introduction

Albireo

A bangumi auto download and management project This is the backend part.

This repository is archived, the project is suceeded by project-mira: https://github.com/irohalab/Albireo

Motivation

There are an existed resolution for auto download bangumi from dmhy or other bt site by using flexget to parse the rss feed periodically. but that resolution is hard to manage the downloaded file when the number of bangumi is growing. So I write this project to make the same way to auto download bangumi but associate the downloaded file with information provided by bangumi.tv. further more, the information can be used for more user friendly function.

Installation

Server

Run with Docker

Nginx Configuration

Scheduler

HTTP API

Upgrade From Old Version

Client Apps

Sentry

Installation

requirements: python 2.7, deluge ( >= 1.3.13 ), postgresql 9.3 and above, ffmpeg, nodejs, python-imaging

dependencies:

  • SQLAlchemy 1.0
  • psycopg2
  • flask 0.10
  • flask-login 0.0.3
  • PyYAML
  • Twisted
  • feedparser
  • service_identity
  • requests > 2.4.2
  • alembic
  • subprocess32
  • cfscrape
  • Flask-Mail
  • colorthief
  • raven
  • bleach

NOTE: ffmpeg is presume accessible with ffmpeg command

config file

Setup your config file by copying the config/config-sample.yml to config/config.yml, then modify the database and deluge config on demand

There are some config that must be modified before your run the project

  • download

    • location this is the default location of downloaded file, you should set this absolute path to your own download directory which your application and deluge has the permission to write
  • app_secret_key this is used by flask to encrypt session for security reason

  • app_secret_password_salt this is used for generate some token with hash salt

  • site site related information

    • name will be appeared in some email template
    • host will be used for link in email
    • protocol will be used for link in email
  • mail used by Flask-Mail.

init database

using tools.py in the root directory of this project to init db

$ python tools.py --db-init # create tables if not exists

$ python tools.py --user-add admin 1234  # admin is username 1234 is password

$ python tools.py --user-promote admin 3  # admin is username 3 is the level, currently means super user

set your server locale

To avoid some unicode issues, it is recommended to set locale of your server

Server

the server is a flask app which provide http API for management and end user page (currently not completed).

In development mode, using flask built-in server:

run python server.py, if you set the environment variable DEBUG=True, the debug info will be print to log

In production mode, using twistd as WSGI container

twistd -n web --port 5000 --wsgi appd.app

Nginx Configuration

To serve the static files like images and videos, you need to setup a static file server, we recommend using nginx. Here are nginx configurations.

You need to serve the following url pattern.

  • bangumi cover: {http|https}://{youdomain}/pic/{bangumi_id}/cover.jpg
  • episode thumbnail: {http|https}://{youdomain}/pic/{bangumi_id}/thumbnails/{episode_no}.png
  • video: {http|https}://{youdomain}/video/{bangumi_id}/{path_to_video}

explanation

  • yourdomain is the configured domain in config/config.yml file domain section
  • bangumi_id is the bangumi id which is a uuid string
  • episode_no is the episode number for certain episode
  • path_to video is video file path relative to download path which configured in your config file.

In fact, you just need to take the path part after /pic/ and append to your download location. the actual file is there.

For example your download path is /path/to/videos which is set in config/config.yml download location section

server {
	listen 8000 default_server;
	
	root /path/to/videos;
	
	server_name localhost;
	
	location ~ ^(?:/pic|/video)/(.+) {
		try_files /$1 $uri =404;
	}
}

According to your environment and configuration, the nginx configuration may different from this example.

Scheduler

Scheduler is the core of this project ,it work like an cron daemon and periodically visit the bangumi table to see if there are episode need to be downloaded.

To run Scheduler, run python scheduler.py is enough, if you set environment variable DEBUG to True, debug info will be printed.

Usage:

You need to add some keywords in the admin bangumi detail page for the site you want scan. currently dmhy and acg.rip are supported. the rule for keywords can be found in corresponding site's help document.

Client Apps

Official

Web App + Admin Console: https://github.com/lordfriend/Deneb

Community

Android App

Megumin contains all function except the admin console. support Android TV and mobile.

Get On Google Play

Mana Android client for Albireo.Use todo-mvp pattern

Get On Google Play

Sentry

If you are developer, you may want to receive and collect crash log. This function is already integrated. We use Sentry to collect crash log and make an alert to developer.

To enable Sentry, you need copy and rename config/sentry-sample.yml to config/sentry.yml and then modify the web_api and scheduler to your own DSN. It is suggested using different dsn for each one, but use the same is ok.

albireo's People

Contributors

herringtondarkholme avatar ktachibanam avatar lordfriend avatar qip avatar ykelvis 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

albireo's Issues

TypeError: object of type 'NoneType' has no len()

https://sentry.io/nyasoft/albireo-server-prod/issues/712382893/

TypeError: object of type 'NoneType' has no len()
(1 additional frame(s) were not displayed)
...
  File "flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "flask_login/utils.py", line 261, in decorated_view
    return func(*args, **kwargs)
  File "service/auth.py", line 14, in func_wrapper
    return func(*args, **kwargs)
  File "routes/admin.py", line 75, in search_bangumi
    return admin_service.search_bangumi(type, name, offset, count)
  File "service/admin.py", line 140, in search_bangumi
    if len(bgm_list) == 0:

object of type 'NoneType' has no len()

Image Fetch Unsuccessful

When Add a new bangumi in admin, the image of bangumi is not fetched successfully. This results a serious error in home/on_air api which the cover_image property is null.

bangumi.tv returns an none json response

When searching 在下坂本,有何貴幹? from bangumi.tv an error is occurred.

2016/06/05 20:55:37 _internal:87 192.168.1.3 - - [05/Jun/2016 20:55:37] "GET /api/admin/query?name=%E5%9C%A8%E4%B8%8B%E5%9D%82%E6%9C%AC%EF%BC%8C%E6%9C%89%E4%BD%95%E8%B2%B4%E5%B9%B9%EF%BC%9F HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/konomi/.virtualenv/albireo/lib/python2.7/site-packages/flask_login.py", line 792, in decorated_view
    return func(*args, **kwargs)
  File "/home/konomi/PycharmProjects/Albireo/service/auth.py", line 13, in func_wrapper
    return func(*args, **kwargs)
  File "/home/konomi/PycharmProjects/Albireo/routes/admin.py", line 60, in search_bangumi
    bgm_content = json.loads(content)
  File "/usr/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

should make some fallback response

Tools for download all bangumi cover image to server file system

service.admin class has private method to download bangumi cover image to server. this method should be public accessible.

add a new command line method in tools.py to scan all bangumi without local image cover and then downloaded it using service.admin save_bangumi_cover method

Add Telegram bot

The design philosophy of Albireo is automatically complete everything. So the less human operation the better of the system is. What we need here is to notify the end user or the management team an episode is downloaded when it is done. This also help the busy user remember keeping up the progress of a bangumi because most bangumi updates weekly.

Telegram is a really nice im software which I think most of our users have already used that. And it also provides a set of powerful API to achieve this feature.

Here are the specification

  • The bot will only notify the user if the user authorize the Albireo to notify him/her.
  • The bot will only notify the user when the bangumi is being watched by the user
  • The bot will only notify the user when not in the slient time
  • Notification message should contains a Link to the episode-detail page.

Occasionally 401

It is very strange which user already login, some api request occasionally return 401, which is very frequent.
The first time I found this bug is in admin page

How to set up with docker?

After docker build ., the image was successfully built. However, when I typed next instructions, following error occurred.

02:58 Albireo (master) ✗ docker run --rm -it -v "latest:/albireo" -p 127.0.0.1:5000:5000 albireo
 * Starting PostgreSQL 9.3 database server                                                                                                                                                         [ OK ]
python: can't open file '/albireo/server.py': [Errno 2] No such file or directory

My environments:

✘ 02:58 Albireo (master) ✗ docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
albireo             latest              112a08e5bc6b        3 minutes ago       815MB
nextcloud           latest              6cec9cff80aa        2 weeks ago         593MB
ubuntu              14.04               3b853789146f        3 weeks ago         223MB
02:58 Albireo (master) ✗ ls
CHANGELOG.md        README.md           alembic             appd.py             domain              import.py           rpc                 taskrunner          utils
Dockerfile          Scheduler.py        alembic.ini.example config              download_adapter    requirements.txt    server.py           templates           web_hook
LICENSE             __init__.py         apiary.apib         config.yml          feed_scanner        routes              service             tools.py

No task resume implemented

A task is designed to make an complex operation atomic and can resume from an exception. But currently no current resume implementation found. This leads to a serious problem which make some delete operation never executed again whenever it failed.

An proper implementation is necessary to make the task design robust and useful.

Searching query should be case insensitive.

The case sensitive searching is not very convenient in most case. eg. When you what to find an anime named "NEW GAME!!" you may type new game for searching, but it returns nothing although anime "NEW GAME!" and "NEW GAME!!" are already in database.

Stop All Scanner and task when deluge is down

Currently the connectivity with deluge daemon is only checked when scheduler starting. But when deluge daemon is down, all scanner and task continue running as normal, this will make some potential pollution data in database. So a straight forward solution for this situation is stop all scanner and task when deluge daemon connection is broken.

Advanced match rule when crawling

First, can BANGUMI.MOE be able to customize the label?

I can only use fixed tags when I add "sin七宗罪" and can not be retrieved effectively.
For example, the key words: "sin七宗罪 简体中文 mp4"
results:
qq20170523-173231

   "Sin Nanatsu no Taizai" and "sin Nanatsu no Taizai - Zangeroku" are different, but I can not pick out "sin Nanatsu no Taizai".

AttributeError: 'dict' object has no attribute '__dict__'

https://sentry.io/nyasoft/albireo-server-prod/issues/605647233/

AttributeError: 'dict' object has no attribute '__dict__'
(2 additional frame(s) were not displayed)
...
  File "service/auth.py", line 14, in func_wrapper
    return func(*args, **kwargs)
  File "routes/home.py", line 37, in my_bangumi
    return watch_service.my_favorites(current_user.id, status)
  File "service/watch.py", line 235, in my_favorites
    utils.process_bangumi_dict(bgm, bangumi_dict)
  File "utils/common.py", line 68, in process_bangumi_dict
    bangumi_dict['cover_image'] = self.convert_image_dict(row2dict(bangumi.cover_image))
  File "utils/db.py", line 7, in row2dict
    d = row.__dict__

'dict' object has no attribute '__dict__'

Unable to deploy on a Windows machine?

Tried to use Albireo on a PC, but got stuck with the databases.

I installed all the dependencies, and latest mysql server for Windows

But when I tried to init the database(python tools.py --db-init), an exception is always raised:

File "D:\Workspace\python2.7\lib\site-packages\psycopg2\__init__.py", line 164, in connect
    conn = _connect(dsn, connection_factory=connection_factory, async=async)
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) expected authentication request from server, but received

this exception is also raised when I try to start the server directly. ( python server

Also I've tried to test the connection using:

import psycopg2
conn = psycopg2.connect(database='albireo', user='postgres', password='123456', host='localhost', port='5550')

It also comes up with the same problem.

But when I try to test the connection using MySQL Workbench, I'm able to login and the connection is good. So the username/password/port should be good, and SSL is not enabled.

Can you help me with it? Or has anyone successfully deployed Albireo on a PC?

P.S. My installed module versions are:
SQLAlchemy v1.1.5 (I also tried 1.0.0
psycopg2 v2.6.2

API Proposal: Capture any frame and return image

For this Proposal

A new API is required to take a capture of given video frame and return the image for future sharing. once more, the captured image should be kept for a while and clean up automatically.

The new API should take 2 required parameter:

  • file_path for ffmpeg to take capture on target video file
  • time for ffmpeg to seek the special frame to capture

Return an image url of generated capture file this url should be unique and temporarily available.

To clean up old image of temporary file, A new task runner is required. and it is also require the temporary file to have some timestamp information to identity its created date without relying on the file system feature.

Collection of animation distribution lists provide data sources

I noticed that BANGUMI.MOE/DMHY/acg.rip provided rss.
If you join a module to collect this information, and provide regular expression syntax search will be better?

But I'm not too familiar with python, I might use javascript. Module or API ✨

How do you think about it?

encoding issue in video manager

Some path of video file may contain non ascii characters, as a result, the video manger will fail to generate thumbnail for a certain video file path.

500 Error

https://suki.moe/#/play/e8a305e8-044c-40ec-80bf-0ed87712eb60

Stdout:
2016-06-11 16:51:43+0000 [-] "172.17.0.1" - - [11/Jun/2016:16:51:42 +0000] "GET /api/home/episode/e8a305e8-044c-40ec-80bf-0ed87712eb60 HTTP/1.0" 500 291 "https://suki.moe/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.84 Safari/537.36"

StdErr:

2016/06/11 16:51:43 app:1423 Exception on /api/home/episode/e8a305e8-044c-40ec-80bf-0ed87712eb60 [GET]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/local/lib/python2.7/dist-packages/flask_login.py", line 792, in decorated_view
    return func(*args, **kwargs)
  File "/home/herbertqiao/Albireo/routes/home.py", line 35, in episode_detail
    return bangumi_service.episode_detail(episode_id)
  File "/home/herbertqiao/Albireo/service/bangumi.py", line 73, in episode_detail
    raise error
UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-5: ordinal not in range(128)

Add support for episode "variant"

I'd like to add support for scrapping, storing and displaying "variants" of an episode, e.g. "raw-meat" (no subtitle), Chinese-subtitled, Chinese-Japanese subtitled, etc.
The model should be generic enough so that the available variants are not hard-coded but flexible.

Add support for modifying more fields of a bangumi

Currently many fields of bangumi table is locked after it is created. As a new issue occurred. We need to support modify more fields of bangumi which make it be available to modify episode list and episode number as some of the fields maybe not accurate when the bangumi created.

Bangumi table create_time and update_time default value is set incorrectly

In domain/Bangumi.py file, we have the following definition.

class Bangumi(Base):
    # some other fields
    create_time = Column(TIMESTAMP, default=datetime.now(), nullable=False)
    update_time = Column(TIMESTAMP, default=datetime.now(), nullable=False)

this definition for default value of the two fields will make a wrong time for the fields. because this default value will be set permanently to the application start time. this is extremely wrong.

A fix solution is remove function call the default field for those timestamp and date column.

optimise thumbnail generating speed

currently when seeking from middle of an video will result a long seeking time.
by move the seeking switch to the start will speed up the seeking speed.

ffmpeg  -y -ss %s -vframes 1-i "%s"  "%s"

Server stuck at regenerate thumbnail.

Server will stuck when genrate thumbnail. server.py show logs as follow:

2016/05/28 15:17:36 _internal:87 172.17.0.1 - - [28/May/2016 15:17:36] "GET /api/home/episode/41765680-53bd-4086-a03c-bda8f973630a HTTP/1.0" 200 -
ffmpeg version N-80026-g936751b Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab
  libavutil      55. 24.100 / 55. 24.100
  libavcodec     57. 42.100 / 57. 42.100
  libavformat    57. 36.100 / 57. 36.100
  libavdevice    57.  0.101 / 57.  0.101
  libavfilter     6. 45.100 /  6. 45.100
  libavresample   3.  0.  0 /  3.  0.  0
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc    54.  0.100 / 54.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/Albireo/3883cb09-c93f-42d4-b101-d4a3cdebb1d8/[EMD][Netoge no Yome wa Onnanoko ja Nai to Omotta][01][GB][X264_AAC][1280X720]/[EMD][Netoge no Yome wa Onnanoko ja Nai to Omotta][01][GB][X264_AAC][1280X720].mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1iso6
    creation_time   : 2016-04-07 15:38:26
  Duration: 00:24:30.09, start: 0.000000, bitrate: 1302 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 1202 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)
    Metadata:
      creation_time   : 2016-04-07 15:38:26
    Stream #0:1(new): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 95 kb/s (default)
    Metadata:
      creation_time   : 2016-04-07 15:26:15
File '/data/Albireo/3883cb09-c93f-42d4-b101-d4a3cdebb1d8/thumbnails/1.png' already exists. Overwrite ? [y/N] 2016/05/28 15:20:34 _internal:87  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

Maybe caused by a wrong cmd line and single thread.

recover from database connection lost

2016/07/01 11:35:58 Scheduler:156 (psycopg2.OperationalError) terminating connection due to administrator command
SSL connection has been closed unexpectedly
 [SQL: 'SELECT bangumi.id AS bangumi_id, bangumi.bgm_id AS bangumi_bgm_id, bangumi.name AS bangumi_name, bangumi.name_cn AS bangumi_name_cn, bangumi.eps AS bangumi_eps, bangumi.summary AS bangumi_summary, bangumi.image AS bangumi_image, bangumi.air_date AS bangumi_air_date, bangumi.air_weekday AS bangumi_air_weekday, bangumi.rss AS bangumi_rss, bangumi.eps_regex AS bangumi_eps_regex, bangumi.status AS bangumi_status, bangumi.create_time AS bangumi_create_time, bangumi.update_time AS bangumi_update_time \nFROM bangumi \nWHERE bangumi.status = %(status_1)s AND bangumi.rss IS NOT NULL'] [parameters: {'status_1': 1}]
Traceback (most recent call last):
  File "/home/herbertqiao/Albireo/Scheduler.py", line 119, in _scan_bangumi_in_thread
    for bangumi in result:
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2736, in __iter__
    return self._execute_and_instances(context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2751, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1146, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1139, in _execute_context
    context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/default.py", line 450, in do_execute
    cursor.execute(statement, parameters)
OperationalError: (psycopg2.OperationalError) terminating connection due to administrator command
SSL connection has been closed unexpectedly
 [SQL: 'SELECT bangumi.id AS bangumi_id, bangumi.bgm_id AS bangumi_bgm_id, bangumi.name AS bangumi_name, bangumi.name_cn AS bangumi_name_cn, bangumi.eps AS bangumi_eps, bangumi.summary AS bangumi_summary, bangumi.image AS bangumi_image, bangumi.air_date AS bangumi_air_date, bangumi.air_weekday AS bangumi_air_weekday, bangumi.rss AS bangumi_rss, bangumi.eps_regex AS bangumi_eps_regex, bangumi.status AS bangumi_status, bangumi.create_time AS bangumi_create_time, bangumi.update_time AS bangumi_update_time \nFROM bangumi \nWHERE bangumi.status = %(status_1)s AND bangumi.rss IS NOT NULL'] [parameters: {'status_1': 1}]
2016/07/01 11:50:58 Scheduler:156 (sqlalchemy.exc.InvalidRequestError) Can't reconnect until invalid transaction is rolled back [SQL: u'SELECT bangumi.id AS bangumi_id, bangumi.bgm_id AS bangumi_bgm_id, bangumi.name AS bangumi_name, bangumi.name_cn AS bangumi_name_cn, bangumi.eps AS bangumi_eps, bangumi.summary AS bangumi_summary, bangumi.image AS bangumi_image, bangumi.air_date AS bangumi_air_date, bangumi.air_weekday AS bangumi_air_weekday, bangumi.rss AS bangumi_rss, bangumi.eps_regex AS bangumi_eps_regex, bangumi.status AS bangumi_status, bangumi.create_time AS bangumi_create_time, bangumi.update_time AS bangumi_update_time \nFROM bangumi \nWHERE bangumi.status = %(status_1)s AND bangumi.rss IS NOT NULL'] [parameters: [immutabledict({})]]
Traceback (most recent call last):
  File "/home/herbertqiao/Albireo/Scheduler.py", line 119, in _scan_bangumi_in_thread
    for bangumi in result:
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2736, in __iter__
    return self._execute_and_instances(context)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/query.py", line 2751, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 914, in execute
    return meth(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1010, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1078, in _execute_context
    None, None)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1341, in _handle_dbapi_exception
    exc_info
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/compat.py", line 200, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb, cause=cause)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1071, in _execute_context
    conn = self._revalidate_connection()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 391, in _revalidate_connection
    "Can't reconnect until invalid "

Alert admin when a bangumi is behind the schedule

Usually, each episode of a certain bangumi has its airdate and the actual resource for those episodes is usually publish one day later, if an episode is not finished after the airdate by a certain time. an alert should send to admin's mail to address the problem.

user authentication is really slow

As I observed, The /api/info api is significantly slow than other api. This make a long initial render time.
screen shot 2016-07-19 at 8 27 37 pm

This may caused by some design flaw or memory leak. A investigation is need.

API undefined exception return a html document.

For API request, which can raise an exception that may not be defined, should always return json response. But actually, any undefined exception return a html document response which will cause a incomprehensible message in client.

Save Cover Error.

Get cover.jpg failed. May due to cookie and UA

    <div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">Please enable cookies.</div>
    <div id="cf-error-details" class="cf-error-details-wrapper">
      <div class="cf-wrapper cf-header cf-error-overview">
        <h1>
          <span class="cf-error-type" data-translate="error">Error</span>
          <span class="cf-error-code">1010</span>
          <small class="heading-ray-id">Ray ID: 2aea38c23b041932 &bull; 2016-06-06 07:41:24 UTC</small>
        </h1>
        <h2 class="cf-subheadline" data-translate="error_desc">Access denied</h2>
      </div><!-- /.header -->

      <section></section><!-- spacer -->

      <div class="cf-section cf-wrapper">
        <div class="cf-columns two">
          <div class="cf-column">
            <h2 data-translate="what_happened">What happened?</h2>
            <p>The owner of this website (lain.bgm.tv) has banned your access based on your browser's signature (2aea38c23b041932-ua48).</p>
          </div>


        </div>
      </div><!-- /.section -->

How to turn on scheduled tasks ?

My understanding:

Automatic scanning rss found new resources on -> deluge download -> store information

But the Scheduler document says "You need to add some keywords in the admin bangumi detail page for the site you want scan."

Then need to manually add keywords? "Admin bangumi detail page" What does it mean?

TypeError: episode_history() got an unexpected keyword argument 'last_watch_time'

https://sentry.io/organizations/nyasoft/issues/1176706840/?referrer=github_plugin

TypeError: episode_history() got an unexpected keyword argument 'last_watch_time'
  File "flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "flask_login/utils.py", line 261, in decorated_view
    return func(*args, **kwargs)
  File "routes/watch.py", line 46, in episode_history
    last_watch_time=data.get('last_watch_time'))

episode_history() got an unexpected keyword argument 'last_watch_time'

A Scanner can scan all episodes with incomplete information

There should be scanner can scan all episodes with incomplete information like lack of episode name.
Because the information fetched from bangumi.tv is usually incomplete when a new bangumi is just on air, it's episodes information is not published by the anime publisher. it is required to fill those information automatically.

The scanner should be scheduled to run once per day and the best timing is at the midnight.

To avoid potential concurrency written, it is recommended to pause the bangumi scanner when executing this scanner .

IOError: image file is truncated

https://sentry.io/nyasoft/albireo-scheduler-prod/issues/546320403/

IOError: image file is truncated
  File "utils/image.py", line 18, in get_dominant_color
    (r, g, b) = color_thief.get_color(quality=quality)
  File "dist-packages/colorthief.py", line 50, in get_color
    palette = self.get_palette(5, quality)
  File "dist-packages/colorthief.py", line 63, in get_palette
    image = self.image.convert('RGBA')
  File "PIL/Image.py", line 842, in convert
    self.load()
  File "PIL/ImageFile.py", line 204, in load
    raise IOError("image file is truncated")

image file is truncated

Add Bangumi.tv account binding

As we can see, nearly all the information of bangumi is fetched from bangumi.tv, We can also use that site to extend the application. There are many features can be added with the account binding.

For examples:

  • add comment in each bangumi or episode page with bangumi.tv comment api.
  • add watching progress management for bangumi.
  • other features you can imagine.

So it is necessary for the future extend to bind user's bangumi.tv account. This change may result in the database schema changing. So it is needed to use alembic to make database upgrade more reliable.

Episode number is not matched

episode_regex_tuple requires two digits for season number, but in some cases there's only one.
'\.S\d{2}E(\d{2})\.'
下町火箭.Shitamachi.Rocket.S2E01.Chi_Jap.HDTVrip.1280X720.mp4

Add tracker info to magnet of bangumi.moe

currently magnet URI from bangumi.moe search API has only hash. this results the torrent with no trackers info too. Sometimes it can be extremely slow to download a torrent which has no tracker info.

A solution is analyzing the magnet URI and append the missing part which is a fixed set of trackers. and use the complimented magnet URI to download the torrent.

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.