Coder Social home page Coder Social logo

skuill / concertbuddy Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 1.05 MB

A Telegram bot that will become your buddy at a concert, written in C#/.NET 😎

C# 99.50% Dockerfile 0.50%
music setlist concert telegram telegram-bot setlistfm lastfm spotify c-sharp azlyrics

concertbuddy's Introduction

ConcertBuddy

CodeFactor

Table of contents

General info

Are you planning to go to the concert? This telegram bot will be your companion, like a good buddy! 😎

He can tell you the biography of the artist/band, find out the actual setlist from the last concerts, play the track and show the lyrics.

Just write the artist/band name to the ConcertBuddy bot and enjoy!

Features

A few of the things you can do with ConcertBuddy:

  • ✅ Search artist / band by name
    • MusicBrainz
  • ✅ Read artist / band biography
    • Last.fm
  • ✅ View setlists from recent concerts
    • Setlist.fm
  • ✅ Listen to tracks
    • Directly from: Yandex
    • External link: Spotify
  • ✅ Read the lyrics of the tracks
    • Different lyric providers: AZLyrics, Genius, SongLyrics, MusixMatch

Feedback

Feel free to send me feedback on Telegram or file an issue. Feature requests are always welcome.

Technologies

Project is created with:

  • .NET: 6.0
  • Microsoft Visual Studio Community 2022
  • docker

Built with

  • Telegram.Bot - the most popular .NET Client for 🤖 Telegram Bot API
  • LyricsScraperNET - 🎼 a library for .NET that provides an API to search for lyrics of a song from the web
  • SpotifyAPI-NET - a client for Spotify's Web API, written in .NET
  • MusicBrainzAPI - Implementation of the MuzicBrainz API v2
  • Inflatable.Lastfm - Last.fm SDK for modern .NET platforms
  • Genius.NET - C# library to access the Genius REST API in .NET
  • HtmlAgilityPack - agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...)
  • Serilog - simple .NET logging with fully-structured events
  • Yandex.Music API - unofficial wrapper for the Yandex.Music API

Documentation

Hosting

The bot is launched on the Ubuntu 22.10 64bit server DigitalOcean droplet in a docker container from docker hub repository. It costs 6$/month.

Deployment

  1. Create and configure ConcertBuddy/ConcertBuddy.ConsoleApp/appsettings.json file with settings Configuration.cs from template appsettings.template.json.
  2. Build and publish docker image with Dockerfile to docker hub registry.
  3. Use docker-compose.yml to run container.

Environments

Name Link
Development TestConcertBuddy
Production ConcertBuddy

Logging

The serilog adapter is used for event logging. Logs are written to the console, debug, file. Log rotation is configured. Logging settings are set in appsettings.json. Example: appsettings.template.json

Roadmap

Visit github project page or issue board

Release Notes

v0.1.1 (03.09.23):

  • Fixed a problem with lyric searching (Issue 33)
  • Use LyricsScraperNET library instead of LyricsScraper project.
  • Updated external libraries to the latest version (Spotify, Telegram, Yandex)

v0.1.0 (28.10.22):

BreakingChanges:

  • Refactoring. MusicSearcherClient has many responsibilities and bottleneck (Issue 30)
  • Use nuget package of Yandex api instead of project reference (Issue 21)

Bugfixes:

  • Map properly MusicBrainz to Spotify track while searching (Issue 29)
  • Track searching will return nothing if track not found in spotify (Issue 27)
  • Can't find Wu tang artist's information and tracks (Issue 28)
  • Can't initialize Yandex client! System.Net.WebException: The remote server returned an error: (400) Bad Request. (Issue 31)

v0.0.8 (04.02.22. It's my Bday 🎂):

Bugfixes:

  • Track searching will return nothing if track not found in spotify (Issue 27)
  • Disable page navigation if nothing found (Issue 26)

v0.0.7 (30.01.22):

  • Added receiving artist's top 10 tracks from Spotify (Issue 9)

v0.0.6 (25.01.22):

  • Catch unhandled exceptions and log them. (Issue 24)
  • Configure write logs to file with rotation with docker volume. (Issue 25)

v0.0.5 (24.01.22):

  • Listening to the track directly in the telegram. Use Yandex track storage. (Issue 8)

v0.0.4 (21.01.22):

Bugfixes:

  • Made SearchLyric async. (Issue 16)
  • Remove async from telegram messages validation. Move callback messages in MessageHelper. (Issue 18)

v0.0.3 (21.01.22):

  • Migrate app.config to appsettings.json with DI.

v0.0.2 (19.01.22):

  • Fixed async task order in SearchArtistByMBID method.
  • Rename methods with Async.
  • Added some TODO comments.

v0.0.1 (12.01.22):

  • Added MemoryCache when searching for artists by mbid to reduce API calls.
  • Fixed logs format with date and scope.
  • Publish docker version 0.0.1 and deploy on server. 🎉

Support

If you want to support this project or my work in general, you can donate via the link below.

This will always be optional! Thank you! 😉

  • "Buy Me A Coffee"
  • "Tinkoff Donate Button"

concertbuddy's People

Contributors

skuill avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

concertbuddy's Issues

Refactoring. MusicSearcherClient has many responsibilities and bottleneck

Transfer the logic of music search (MusicSearcherClient ) on platforms (Spotify, Yandex) in the identified classes and the track/artist objects passed between them, filling in the necessary properties in the methods.

MusicTrack and MusicArtist contains contain redundant information from every platform.

Map properly MusicBrainz to Spotify track while searching

Spotify don't use MBID and use it's own ID for artists/tracks.
We can't compare artistName. For example for artist "ноганно" actual spotify name is "noganno".
Now we return first result from searching artist/track.

For example (false search):
image

Allow custom track name in telegram bot

image
I'm trying to send an audio message using an external audio link. I would like to specify the performer and title. But setting these parameters has no effect when the method is called.

"Title, etc are set as ID3 tags"
It can be set with downloading track, changing metadata and sending via file

Can't find Wu tang artist's information and tracks

Logs:

2022-02-01 09:49:27.143 +00:00 [Debug] [MusicSearcher.MusicSearcherClient] Find artists for [Wu tang]: Wu‐Tang Clan [score: 100]; Wu tang Switch [score: 88]; Wu-Tang Killa Bees [score: 84]; Wu-Tang Yellow Jacketz [score: 79]; Ghostface Killah [score: 58]
2022-02-01 09:49:31.823 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.ArtistCommand] Handle [/artist] command: [/artist 0febdcf7-4e1f-4661-9493-b40427de2c13]
2022-02-01 09:49:32.159 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist by mbid [0febdcf7-4e1f-4661-9493-b40427de2c13] from LastFM
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.GetSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 378
at MusicSearcher.MusicSearcherClient.SearchArtistByMBID(String artistMBID) in /src/MusicSearcher/MusicSearcherClient.cs:line 118
2022-02-01 09:49:35.585 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TopCommand] Handle [/top] command: [/top track 0febdcf7-4e1f-4661-9493-b40427de2c13]
2022-02-01 09:49:35.826 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist by mbid [0febdcf7-4e1f-4661-9493-b40427de2c13] from LastFM
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.GetSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 378
at MusicSearcher.MusicSearcherClient.SearchArtistByMBID(String artistMBID) in /src/MusicSearcher/MusicSearcherClient.cs:line 118
2022-02-01 09:49:35.834 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist [] from Spotify.
System.ArgumentException: String is empty or null (Parameter 'query')
at SpotifyAPI.Web.Ensure.ArgumentNotNullOrEmptyString(String value, String name)
at SpotifyAPI.Web.SearchRequest..ctor(Types type, String query)
at MusicSearcher.MusicSearcherClient.SearchSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 199
2022-02-01 09:49:35.839 +00:00 [Error] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TopCommand] Can't find top tracks for artist [] with mbid [0febdcf7-4e1f-4661-9493-b40427de2c13]
2022-02-01 09:49:45.565 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.SetlistsCommand] Handle [/setlists] command: [/setlists 1 0 0febdcf7-4e1f-4661-9493-b40427de2c13]
2022-02-01 09:49:51.968 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.SetlistCommand] Handle [/setlist] command: [/setlist 0febdcf7-4e1f-4661-9493-b40427de2c13 438d4b2f]
2022-02-01 09:50:01.600 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TrackCommand] Handle [/track] command: [/track 0febdcf7-4e1f-4661-9493-b40427de2c13 Shame on a Nigga]
2022-02-01 09:50:02.146 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist by mbid [0febdcf7-4e1f-4661-9493-b40427de2c13] from LastFM
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.GetSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 378
at MusicSearcher.MusicSearcherClient.SearchArtistByMBID(String artistMBID) in /src/MusicSearcher/MusicSearcherClient.cs:line 118
2022-02-01 09:50:02.453 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shame on a Nigga] for artist [] from Spotify.
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.SearchSpotifyTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 184
2022-02-01 09:50:02.999 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shame on a Nigga] for artist [] from Yandex.
System.Exception: Can't get track [Shame on a Nigga] for artist [] from Yandex.
at MusicSearcher.MusicSearcherClient.SearchYandexTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 162
2022-02-01 09:50:39.299 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TrackCommand] Handle [/track] command: [/track 0febdcf7-4e1f-4661-9493-b40427de2c13 Shimmy Shimmy Ya]
2022-02-01 09:50:39.535 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist by mbid [0febdcf7-4e1f-4661-9493-b40427de2c13] from LastFM
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.GetSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 378
at MusicSearcher.MusicSearcherClient.SearchArtistByMBID(String artistMBID) in /src/MusicSearcher/MusicSearcherClient.cs:line 118
2022-02-01 09:50:39.814 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shimmy Shimmy Ya] for artist [] from Spotify.
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.SearchSpotifyTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 184
2022-02-01 09:50:40.215 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shimmy Shimmy Ya] for artist [] from Yandex.
System.Exception: Can't get track [Shimmy Shimmy Ya] for artist [] from Yandex.
at MusicSearcher.MusicSearcherClient.SearchYandexTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 162
2022-02-01 09:51:06.827 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TrackCommand] Handle [/track] command: [/track 0febdcf7-4e1f-4661-9493-b40427de2c13 Shimmy Shimmy Ya]
2022-02-01 09:51:07.066 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist by mbid [0febdcf7-4e1f-4661-9493-b40427de2c13] from LastFM
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.GetSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 378
at MusicSearcher.MusicSearcherClient.SearchArtistByMBID(String artistMBID) in /src/MusicSearcher/MusicSearcherClient.cs:line 118
2022-02-01 09:51:07.219 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shimmy Shimmy Ya] for artist [] from Spotify.
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.SearchSpotifyTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 184
2022-02-01 09:51:07.429 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shimmy Shimmy Ya] for artist [] from Yandex.
System.Exception: Can't get track [Shimmy Shimmy Ya] for artist [] from Yandex.
at MusicSearcher.MusicSearcherClient.SearchYandexTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 162
2022-02-01 09:51:25.627 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TrackCommand] Handle [/track] command: [/track 0febdcf7-4e1f-4661-9493-b40427de2c13 Shimmy Shimmy Ya]
2022-02-01 09:51:25.869 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist by mbid [0febdcf7-4e1f-4661-9493-b40427de2c13] from LastFM
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.GetSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 378
at MusicSearcher.MusicSearcherClient.SearchArtistByMBID(String artistMBID) in /src/MusicSearcher/MusicSearcherClient.cs:line 131
2022-02-01 09:51:26.040 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shimmy Shimmy Ya] for artist [] from Spotify.
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.SearchSpotifyTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 184
2022-02-01 09:51:26.269 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shimmy Shimmy Ya] for artist [] from Yandex.
System.Exception: Can't get track [Shimmy Shimmy Ya] for artist [] from Yandex.
at MusicSearcher.MusicSearcherClient.SearchYandexTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 162
2022-02-01 09:51:29.682 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TrackCommand] Handle [/track] command: [/track 0febdcf7-4e1f-4661-9493-b40427de2c13 Shame on a Nigga]
2022-02-01 09:51:29.936 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist by mbid [0febdcf7-4e1f-4661-9493-b40427de2c13] from LastFM
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.GetSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 378
at MusicSearcher.MusicSearcherClient.SearchArtistByMBID(String artistMBID) in /src/MusicSearcher/MusicSearcherClient.cs:line 131
2022-02-01 09:51:30.095 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shame on a Nigga] for artist [] from Spotify.
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.SearchSpotifyTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 184
2022-02-01 09:51:30.466 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Shame on a Nigga] for artist [] from Yandex.
System.Exception: Can't get track [Shame on a Nigga] for artist [] from Yandex.
at MusicSearcher.MusicSearcherClient.SearchYandexTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 162
2022-02-01 10:00:46.354 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TrackCommand] Handle [/track] command: [/track 0febdcf7-4e1f-4661-9493-b40427de2c13 Gravel Pit]
2022-02-01 10:00:46.716 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't get artist by mbid [0febdcf7-4e1f-4661-9493-b40427de2c13] from LastFM
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.GetSpotifyArtist(String artistName) in /src/MusicSearcher/MusicSearcherClient.cs:line 378
at MusicSearcher.MusicSearcherClient.SearchArtistByMBID(String artistMBID) in /src/MusicSearcher/MusicSearcherClient.cs:line 131
2022-02-01 10:00:46.992 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Gravel Pit] for artist [] from Spotify.
System.InvalidOperationException: Sequence contains no matching element
at System.Linq.ThrowHelper.ThrowNoMatchException()
at System.Linq.Enumerable.First[TSource](IEnumerable1 source, Func2 predicate)
at MusicSearcher.MusicSearcherClient.SearchSpotifyTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 184
2022-02-01 10:00:47.305 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Gravel Pit] for artist [] from Yandex.
System.Exception: Can't get track [Gravel Pit] for artist [] from Yandex.
at MusicSearcher.MusicSearcherClient.SearchYandexTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 162

Track searching will return nothing if track not found in spotify

Logs:
2022-02-01 09:16:06.623 +00:00 [Debug] [ConcertBuddy.ConsoleApp.TelegramBot.Command.TrackCommand] Handle [/track] command: [/track f422e97e-fe40-4c9c-be9a-2bba923539ad Hobby]
2022-02-01 09:16:06.709 +00:00 [Error] [MusicSearcher.MusicSearcherClient] Can't search track [Hobby] for artist [Guf] from Spotify.
System.Exception: Can't get track [Hobby] for artist [Guf] from Spotify.
at MusicSearcher.MusicSearcherClient.SearchSpotifyTrack(String artistName, String trackName) in /src/MusicSearcher/MusicSearcherClient.cs:line 182

image

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.