Skip to main content

External database feeder for the Dakara Project

Project description

Dakara Feeder

Travis CI Build Status Appveyor CI Build status Codecov coverage analysis Code style: black PyPI version PyPI Python versions

Allows to feed the database of the Dakara server remotely.

Installation

This repo is tied with the Dakara server, so you should setup it first:

Other important parts of the project include:

System requirements

  • Python3, to make everything up and running (supported versions: 3.5, 3.6, 3.7 and 3.8);
  • ffmpeg, to extract lyrics and extract metadata from files (preferred way);
  • MediaInfo, to extract metadata from files (slower, alternative way, may not work on Windows).

Linux and Windows are supported.

Virtual environment

It is strongly recommended to use the Dakara feeder within a virtual environment.

Install

Install the package with:

pip install dakarafeeder

If you have downloaded the repo, you can install the package directly with:

python setup.py install

Usage

Commands

The package provides the dakara-feed command which will find songs in the configured directory, parse them and send their data to a running instance of the Dakara server:

dakara-feed
# or
python -m dakara_feed

One instance of the Dakara server should be running. For more help:

dakara-feed -h
# or
python -m dakara_feed -h

Before calling the function, you should create a config file with:

dakara-feed create-config
# or
python -m dakara_feed create-config

and complete it with your values. The file is stored in your user space: ~/.config/dakara on Linux or $APPDATA\Dakara on Windows.

The data extracted from songs are very limited in this package by default, as data can be stored in various ways in song files. You are encouraged to make your own parser, see next subsection.

Making a custom parser

To override the extraction of data from song files, you should create a class derived from dakara_feeder.song.BaseSong. Please refer to the documentation of this class to learn which methods to override, and what attributes and helpers are at your disposal.

Here is a basic example. It considers that the song video file is formatted in the way "title - main artist.ext":

# my_song.py
from dakara_feeder.song import BaseSong

class Song(BaseSong):
    def get_title(self):
        return self.video_path.stem.split(" - ")[0]

    def get_artists(self):
        return [{"name": self.video_path.stem.split(" - ")[1]}]

The file must be in the same directory you are calling dakara-feed, or in any directory reachable by Python. To register your customized Song class, you simply enable it in the config file:

# Custom song class to use
# If you want to extract additional data when parsing files (video, subtitle or
# other), you can write your own Song class, derived from
# `dakara_feeder.song.BaseSong`. See documentation of BaseSong for more details
# on how to proceed.
# Indicate the module name of the class to use.
# Default is BaseSong, which is pretty basic.
custom_song_class: my_song.Song

Now, dakara-feed will use your customized Song class instead of the default one.

Developpment

Install dependencies

Please ensure you have a recent enough version of setuptools:

pip install --upgrade "setuptools>=40.0"

Install the dependencies with:

pip install -e ".[tests]"

This installs the normal dependencies of the package plus the dependencies for tests.

Run tests

Run tests simply with:

python setup.py test

To check coverage, use the coverage command:

coverage run setup.py test
coverage report -m

Hooks

Git hooks are included in the hooks directory.

Use the following command to use this hook folder for the project:

git config core.hooksPath hooks

If you're using git < 2.9 you can make a symlink instead:

ln -s -f ../../hooks/pre-commit .git/hooks/pre-commit

Code style

The code follows the PEP8 style guide (88 chars per line). Quality of code is checked with Flake8. Style is enforced using Black. You need to call Black before committing changes. You may want to configure your editor to call it automatically. Additionnal checking can be manually performed with Pylint.

MIT License

Copyright (c) 2020 Dakara Project

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dakarafeeder-1.6.0.tar.gz (37.4 kB view hashes)

Uploaded Source

Built Distribution

dakarafeeder-1.6.0-py3-none-any.whl (24.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page