Compare commits

...

11 commits

Author SHA1 Message Date
Simon Bruder 327235c451
be less silly next time (hard coded version number where it is dynamic)
All checks were successful
continuous-integration/drone/push Build is passing
2019-06-23 00:15:18 +00:00
Simon Bruder d63397b1ed
make docker image much smaller
Some checks reported errors
continuous-integration/drone/push Build was killed
2019-06-02 09:05:11 +00:00
Simon Bruder 1da5439358 add drone config
All checks were successful
continuous-integration/drone/push Build is passing
2019-03-25 16:25:41 +01:00
Simon Bruder 58c9465add always use latest alpine version 2019-03-25 16:24:07 +01:00
Matthieu Grieger dff929ddc9 Update README.md 2017-05-20 18:04:02 -07:00
Matthieu Grieger 138c1008eb Fixed YouTube playback offsets 2016-11-05 21:30:42 -07:00
Matthieu Grieger 2f6bda5018 Update version number and changelog 2016-11-05 19:41:58 -07:00
Matthieu Grieger a1c5399223 https://github.com/matthieugrieger/mumbledj/issues/182: Added back track/playlist submitter immediate skipping 2016-11-05 19:39:31 -07:00
Matthieu Grieger e1e3a334cd Fix https://github.com/matthieugrieger/mumbledj/issues/180: Panic on playlist with private video 2016-11-05 19:22:58 -07:00
Matthieu Grieger 51db9c3061 Fix https://github.com/matthieugrieger/mumbledj/issues/176: Empty IDs for SoundCloud tracks 2016-08-22 20:20:41 -07:00
Matthieu Grieger 9222608962 Fixed https://github.com/matthieugrieger/mumbledj/issues/174: Fixed deadlock during track skip/finish 2016-08-21 17:58:11 -07:00
14 changed files with 114 additions and 35 deletions

1
.dockerignore Normal file
View file

@ -0,0 +1 @@
Dockerfile

13
.drone.yml Normal file
View file

@ -0,0 +1,13 @@
kind: pipeline
name: default
steps:
- name: docker
image: plugins/docker
settings:
registry: r.sbruder.de
username:
from_secret: docker_username
password:
from_secret: docker_password
repo: r.sbruder.de/mumbledj

View file

@ -1,6 +1,20 @@
MumbleDJ Changelog
==================
### November 5, 2016 -- `v3.2.1`
* Fixed YouTube video offsets. Now YouTube URLs with `?t=<timestamp>` at the end will start the audio playback at the appropriate position.
### November 5, 2016 -- `v3.2.0`
* Fixed a Go panic that would occur when a YouTube playlist contained a private video.
* Added back immediate skipping for tracks/playlists that are skipped by the submitter. This was a feature that was present in the last major version of MumbleDJ but was forgotten when rewriting the bot (sorry!).
### August 22, 2016 -- `v3.1.4`
* Fixed a SoundCloud API response parsing issue that would result in empty IDs for tracks.
* Fixed the startup check for SoundCloud API.
### August 21, 2016 -- `v3.1.3`
* Fixed a deadlock that would occur during the transition from the first to second track in a queue.
### August 14, 2016 -- `v3.1.2`
* Fixed an index out of range crash in the queue skipping function.

View file

@ -1,19 +1,39 @@
FROM alpine:3.3
FROM golang:alpine as builder
ENV GOPATH=/
RUN apk add --no-cache \
build-base \
opus-dev
RUN apk add --update ca-certificates go ffmpeg make build-base opus-dev python aria2
RUN apk upgrade
COPY . /go/src/github.com/matthieugrieger/mumbledj
WORKDIR /go/src/github.com/matthieugrieger/mumbledj
RUN wget https://yt-dl.org/downloads/latest/youtube-dl -O /bin/youtube-dl && chmod a+x /bin/youtube-dl
RUN go get -v \
&& go build -v -ldflags="-s -w"
COPY . /src/github.com/matthieugrieger/mumbledj
COPY config.yaml /root/.config/mumbledj/config.yaml
FROM alpine
WORKDIR /src/github.com/matthieugrieger/mumbledj
RUN adduser -D mumbledj
RUN make
RUN make install
RUN apk del go make build-base && rm -rf /var/cache/apk/*
RUN apk add --no-cache \
aria2 \
libressl \
python2
ENTRYPOINT ["/usr/local/bin/mumbledj"]
RUN wget -O /usr/bin/youtube-dl https://yt-dl.org/downloads/latest/youtube-dl \
&& chmod +x /usr/bin/youtube-dl
RUN wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz \
&& tar xvf ffmpeg-git-amd64-static.tar.xz '*/ffmpeg' || true \
&& mv ffmpeg-git-*-amd64-static/ffmpeg /usr/bin/ffmpeg \
&& rm -rf ffmpeg-git-* \
&& apk add --no-cache upx \
&& upx /usr/bin/ffmpeg \
&& apk del upx
COPY --from=builder /go/src/github.com/matthieugrieger/mumbledj/mumbledj /usr/bin/mumbledj
COPY config.yaml /home/mumbledj/.config/mumbledj/config.yaml
USER mumbledj
ENTRYPOINT ["/usr/bin/mumbledj"]

View file

@ -3,6 +3,8 @@
<p align="center"><b>A Mumble bot that plays audio fetched from various media websites.</b></p>
<p align="center"><a href="https://travis-ci.org/matthieugrieger/mumbledj"><img src="https://travis-ci.org/matthieugrieger/mumbledj.svg?branch=master"/></a> <a href="https://raw.githubusercontent.com/matthieugrieger/mumbledj/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blue.svg"/></a> <a href="https://github.com/matthieugrieger/mumbledj/releases"><img src="https://img.shields.io/github/release/matthieugrieger/mumbledj.svg"/></a> <a href="https://goreportcard.com/report/github.com/matthieugrieger/mumbledj"><img src="https://goreportcard.com/badge/github.com/matthieugrieger/mumbledj"/></a> <a href="https://codecov.io/gh/matthieugrieger/mumbledj"><img src="https://img.shields.io/codecov/c/github/matthieugrieger/mumbledj.svg"/></a> <a href="https://gitter.im/matthieugrieger/mumbledj"><img src="https://img.shields.io/gitter/room/matthieugrieger/mumbledj.svg" /></a></p>
<p align="center"><b>Unfortunately, this project is no longer maintained. Don't expect any responses on bug reports, feature requests, etc. Forks are welcome!</b></p>
## Table of Contents
* [Features](#features)

File diff suppressed because one or more lines are too long

View file

@ -196,6 +196,7 @@ func SetDefaultConfig() {
viper.SetDefault("commands.skip.description", "Places a vote to skip the current track.")
viper.SetDefault("commands.skip.messages.already_voted_error", "You have already voted to skip this track.")
viper.SetDefault("commands.skip.messages.voted", "<b>%s</b> has voted to skip the current track.")
viper.SetDefault("commands.skip.messages.submitter_voted", "<b>%s</b>, the submitter of this track, has voted to skip. Skipping immediately.")
viper.SetDefault("commands.skipplaylist.aliases", []string{"skipplaylist", "sp"})
viper.SetDefault("commands.skipplaylist.is_admin", false)
@ -203,6 +204,7 @@ func SetDefaultConfig() {
viper.SetDefault("commands.skipplaylist.messages.no_playlist_error", "The current track is not part of a playlist.")
viper.SetDefault("commands.skipplaylist.messages.already_voted_error", "You have already voted to skip this playlist.")
viper.SetDefault("commands.skipplaylist.messages.voted", "<b>%s</b> has voted to skip the current playlist.")
viper.SetDefault("commands.skipplaylist.messages.submitter_voted", "<b>%s</b>, the submitter of this playlist, has voted to skip. Skipping immediately.")
viper.SetDefault("commands.toggleshuffle.aliases", []string{"toggleshuffle", "toggleshuf", "togshuf", "tsh"})
viper.SetDefault("commands.toggleshuffle.is_admin", true)

View file

@ -199,7 +199,7 @@ func (q *Queue) Skip() {
q.mutex.Lock()
// If caching is disabled, delete the track from disk.
if q.Length() != 0 && !viper.GetBool("cache.enabled") {
if len(q.Queue) != 0 && !viper.GetBool("cache.enabled") {
DJ.YouTubeDL.Delete(q.Queue[0])
}

View file

@ -47,6 +47,11 @@ func (c *SkipCommand) Execute(user *gumble.User, args ...string) (string, bool,
if DJ.Queue.Length() == 0 {
return "", true, errors.New(viper.GetString("commands.common_messages.no_tracks_error"))
}
if DJ.Queue.GetTrack(0).GetSubmitter() == user.Name {
// The user who submitted the track is skipping, this means we skip this track immediately.
DJ.Queue.StopCurrent()
return fmt.Sprintf(viper.GetString("commands.skip.messages.submitter_voted"), user.Name), false, nil
}
if err := DJ.Skips.AddTrackSkip(user); err != nil {
return "", true, errors.New(viper.GetString("commands.skip.messages.already_voted_error"))
}

View file

@ -58,6 +58,10 @@ func (c *SkipPlaylistCommand) Execute(user *gumble.User, args ...string) (string
if playlist := currentTrack.GetPlaylist(); playlist == nil {
return "", true, errors.New(viper.GetString("commands.skipplaylist.messages.no_playlist_error"))
}
if currentTrack.GetPlaylist().GetSubmitter() == user.Name {
DJ.Queue.SkipPlaylist()
return fmt.Sprintf(viper.GetString("commands.skipplaylist.messages.submitter_voted"), user.Name), false, nil
}
if err := DJ.Skips.AddPlaylistSkip(user); err != nil {
return "", true, errors.New(viper.GetString("commands.skipplaylist.messages.already_voted_error"))
}

View file

@ -264,7 +264,7 @@ commands:
messages:
no_channel_provided_error: "A destination channel must be supplied to move the bot."
channel_doesnt_exist_error: "The provided channel does not exist."
move_successful: "You have successfully moved the bot to <b>%s</b>."
move_successful: "You have successfully moved the bot to <b>%s</b>."
nexttrack:
aliases:
@ -374,6 +374,7 @@ commands:
messages:
already_voted_error: "You have already voted to skip this track."
voted: "<b>%s</b> has voted to skip the current track."
submitter_voted: "<b>%s</b>, the submitter of this track, has voted to skip. Skipping immediately."
skipplaylist:
aliases:
@ -385,6 +386,7 @@ commands:
no_playlist_error: "The current track is not part of a playlist."
already_voted_error: "You have already voted to skip this playlist."
voted: "<b>%s</b> has voted to skip the current playlist."
submitter_voted: "<b>%s</b>, the submitter of this playlist, has voted to skip. Skipping immediately."
toggleshuffle:
aliases:
@ -418,4 +420,4 @@ commands:
parsing_error: "The requested volume could not be parsed."
out_of_range_error: "Volumes must be between the values <b>%.2f</b> and <b>%.2f</b>."
current_volume: "The current volume is <b>%.2f</b>."
volume_changed: "<b>%s</b> has changed the volume to <b>%.2f</b>."
volume_changed: "<b>%s</b> has changed the volume to <b>%.2f</b>."

View file

@ -32,7 +32,7 @@ func init() {
services.DJ = DJ
bot.DJ = DJ
DJ.Version = "v3.1.2"
DJ.Version = "v3.2.1"
logrus.SetLevel(logrus.WarnLevel)
}

View file

@ -52,7 +52,7 @@ func (sc *SoundCloud) CheckAPIKey() error {
if viper.GetString("api_keys.soundcloud") == "" {
return errors.New("No SoundCloud API key has been provided")
}
url := "http://api.soundcloud.com/tracks/vjflzpbkmerb?client_id=%s"
url := "http://api.soundcloud.com/tracks/13158665?client_id=%s"
response, err := http.Get(fmt.Sprintf(url, viper.GetString("api_keys.soundcloud")))
defer response.Body.Close()
if err != nil {
@ -162,7 +162,8 @@ func (sc *SoundCloud) GetTracks(url string, submitter *gumble.User) ([]interface
func (sc *SoundCloud) getTrack(obj *jason.Object, offset time.Duration, submitter *gumble.User) (bot.Track, error) {
title, _ := obj.GetString("title")
id, _ := obj.GetString("id")
idInt, _ := obj.GetInt64("id")
id := strconv.FormatInt(idInt, 10)
url, _ := obj.GetString("permalink_url")
author, _ := obj.GetString("user", "username")
authorURL, _ := obj.GetString("user", "permalink_url")

View file

@ -13,6 +13,8 @@ import (
"math"
"net/http"
"regexp"
"strings"
"time"
"github.com/ChannelMeter/iso8601duration"
"github.com/antonholmquist/jason"
@ -98,9 +100,12 @@ func (yt *YouTube) GetTracks(url string, submitter *gumble.User) ([]interfaces.T
tracks []interfaces.Track
)
dummyOffset, _ := time.ParseDuration("0s")
urlSplit := strings.Split(url, "?t=")
playlistURL = "https://www.googleapis.com/youtube/v3/playlists?part=snippet&id=%s&key=%s"
playlistItemsURL = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet,contentDetails&playlistId=%s&maxResults=%d&key=%s&pageToken=%s"
id, err = yt.getID(url)
id, err = yt.getID(urlSplit[0])
if err != nil {
return nil, err
}
@ -161,7 +166,7 @@ func (yt *YouTube) GetTracks(url string, submitter *gumble.User) ([]interfaces.T
// Unfortunately we have to execute another API call for each video as the YouTube API does not
// return video durations from the playlistItems endpoint...
newTrack, _ := yt.getTrack(videoID, submitter)
newTrack, _ := yt.getTrack(videoID, submitter, dummyOffset)
newTrack.Playlist = playlist
tracks = append(tracks, newTrack)
@ -182,7 +187,13 @@ func (yt *YouTube) GetTracks(url string, submitter *gumble.User) ([]interfaces.T
return tracks, nil
}
track, err = yt.getTrack(id, submitter)
// Submitter added a track!
offset := dummyOffset
if len(urlSplit) == 2 {
offset, _ = time.ParseDuration(urlSplit[1])
}
track, err = yt.getTrack(id, submitter, offset)
if err != nil {
return nil, err
}
@ -190,7 +201,7 @@ func (yt *YouTube) GetTracks(url string, submitter *gumble.User) ([]interfaces.T
return tracks, nil
}
func (yt *YouTube) getTrack(id string, submitter *gumble.User) (bot.Track, error) {
func (yt *YouTube) getTrack(id string, submitter *gumble.User, offset time.Duration) (bot.Track, error) {
var (
resp *http.Response
err error
@ -209,6 +220,9 @@ func (yt *YouTube) getTrack(id string, submitter *gumble.User) (bot.Track, error
return bot.Track{}, err
}
items, _ := v.GetObjectArray("items")
if len(items) == 0 {
return bot.Track{}, errors.New("This YouTube video is private")
}
item := items[0]
title, _ := item.GetString("snippet", "title")
thumbnail, _ := item.GetString("snippet", "thumbnails", "high", "url")
@ -218,15 +232,16 @@ func (yt *YouTube) getTrack(id string, submitter *gumble.User) (bot.Track, error
duration := durationConverted.ToDuration()
return bot.Track{
ID: id,
URL: "https://youtube.com/watch?v=" + id,
Title: title,
Author: author,
Submitter: submitter.Name,
Service: yt.ReadableName,
Filename: id + ".track",
ThumbnailURL: thumbnail,
Duration: duration,
Playlist: nil,
ID: id,
URL: "https://youtube.com/watch?v=" + id,
Title: title,
Author: author,
Submitter: submitter.Name,
Service: yt.ReadableName,
Filename: id + ".track",
ThumbnailURL: thumbnail,
Duration: duration,
PlaybackOffset: offset,
Playlist: nil,
}, nil
}