Code Monkey home page Code Monkey logo

song-request-queue's Introduction

Song Request Queue

Demo

You can try a live demo at https://song-request.grinnz.com. The admin account has the username and password demo, and demo also works as a bot key.

Requirements

  • PostgreSQL 9.5+
  • Perl 5.20+

Setup

  1. Create a PostgreSQL database and user (that can create tables in the database) for the app to use.
$ createuser song_request_user -lP
$ createdb song_request_queue -O song_request_user
  1. Create song_request_queue.conf as a perl configuration file, example:
{
  pg => 'postgresql://user:pass@/dbname',
  hypnotoad => {
    listen => ['http://*:8080'], # 8080 is default for hypnotoad
  },
  logfile => '/var/log/srq.log',
  secrets => ['change this'],
}
  1. Create an empty stopwords file named empty.stop in the tsearch_data subdirectory of your PostgreSQL share directory.
# pg_config --sharedir
/path/to/sharedir
# touch /path/to/sharedir/tsearch_data/empty.stop
  1. Install the perl module prerequisites from the cpanfile.
$ cpanm --installdeps .
  1. Start the application.
$ perl song_request_queue.pl daemon --listen='http://*:3000'

Or with hypnotoad (production web server):

$ hypnotoad song_request_queue.pl

See the Mojolicious deployment cookbook for more information on deployment options.

Users

Admin users must be manually added to the users table (created once the webapp has been run and successfully connected to the database). The binary field password_reset_code can be set to a one-time-use code to allow the user to set a password on the /set_password page.

> INSERT INTO "users" ("username","password_reset_code","is_admin","is_mod") VALUES ('someuser',E'\\xDEADBEEF',true,true);

Admin users can add queue moderators on the /admin page. The reset code will be returned and can be used similarly on the /set_password page.

Song format

Songs can be manually added on the Admin page, but can also be imported in CSV, JSON, or XLSX format. The CSV format is expected to be that exported by the C3 Tools Setlist Manager, or in general to have headers and the following columns (order not important):

  • Song Title
  • Artist
  • Album Name
  • Track #
  • Source
  • Duration

The JSON format is expected to be that exported by Clone Hero, or in general to be an array of JSON objects with the following elements (order not important):

  • songName
  • artistName
  • albumName
  • charterName
  • songLength

The XLSX format is expected to have the following columns (order not important):

  • Song Name
  • Artist
  • Album Name
  • Track
  • Author
  • Duration

Bot Requests

Requests can be sent from a bot to the API endpoints /api/queue/add, /api/queue/update, /api/queue/remove, and /api/queue/stats. The parameters bot_key, requested_by, and query (except for when removing) should be included in the query string. No parameters are required for the queue stats endpoint. bot_key must match a value in the bot_keys array in the config file. The endpoints accept GET requests to accomodate bots with limited HTTP request functionality, but POST should be used when possible to avoid resubmitting requests. The endpoints return a text string indicating success or error that can be displayed by the bot.

song_request_queue.conf:
...
  bot_keys => ['foobar'],
...
GET https://example.com/api/queue/add?bot_key=foobar&requested_by=Grinnz&query=something
GET https://example.com/api/queue/update?bot_key=foobar&requested_by=Grinnz&query=something%20else
GET https://example.com/api/queue/remove?bot_key=foobar&requested_by=Grinnz
GET https://example.com/api/queue/stats

Copyright and License

This software is Copyright (c) 2017 by Dan Book.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

song-request-queue's People

Contributors

grinnz avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

thesoundhaven

song-request-queue's Issues

Song request blacklist

Ability to mark a song so it cannot be requested. Option for behavior: return error that song is blacklisted, or ignore song when searching request

Request limit

Configuration option to limit the number of requests a user can have in the queue at once

Multiple queues per instance

Instead of each queue needing its own database instance, the instance should serve per-user queues from one database.

Random song requests

  • Endpoint to request a random song of a particular category, like genre or artist, etc?
  • Endpoint to request a random result of a search

Mod bot commands

Mod-only bot command APIs like advancing or clearing the queue

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.