Skip to content

Commit

Permalink
Merge branch 'master' into flairs-css
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkeyDo committed Nov 14, 2024
2 parents 0217422 + 3213235 commit 788f069
Show file tree
Hide file tree
Showing 53 changed files with 1,372 additions and 845 deletions.
1 change: 1 addition & 0 deletions .well-known/funding-manifest-urls
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://metabrainz.org/funding.json
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ COPY ./docker/services/spotify_reader/spotify_reader.service /etc/service/spotif
COPY ./docker/services/spotify_reader/spotify_reader.finish /etc/service/spotify_reader/finish
RUN touch /etc/service/spotify_reader/down

# Last.fm importer
COPY ./docker/services/lastfm_importer/consul-template-lastfm-importer.conf /etc/consul-template-lastfm-importer.conf
COPY ./docker/services/lastfm_importer/lastfm_importer.service /etc/service/lastfm_importer/run
COPY ./docker/services/lastfm_importer/lastfm_importer.finish /etc/service/lastfm_importer/finish
RUN touch /etc/service/lastfm_importer/down

# Timescale writer
COPY ./docker/services/timescale_writer/consul-template-timescale-writer.conf /etc/consul-template-timescale-writer.conf
COPY ./docker/services/timescale_writer/timescale_writer.service /etc/service/timescale_writer/run
Expand Down
2 changes: 1 addition & 1 deletion admin/sql/create_tables.sql
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ CREATE TABLE external_service_oauth (
user_id INTEGER NOT NULL, -- FK to "user".id
external_user_id TEXT,
service external_service_oauth_type NOT NULL,
access_token TEXT NOT NULL,
access_token TEXT,
refresh_token TEXT,
token_expires TIMESTAMP WITH TIME ZONE,
last_updated TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BEGIN;

ALTER TABLE external_service_oauth ALTER COLUMN access_token DROP NOT NULL;

COMMIT;
13 changes: 12 additions & 1 deletion docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,24 @@ services:
image: web
volumes:
- ..:/code/listenbrainz:z
command: python3 -m "listenbrainz.spotify_updater.spotify_read_listens"
command: python3 -m "listenbrainz.listens_importer.spotify"
user: "${LB_DOCKER_USER:-root}:${LB_DOCKER_GROUP:-root}"
depends_on:
- redis
- lb_db
- rabbitmq

lastfm_importer:
image: web
volumes:
- ..:/code/listenbrainz:z
command: python3 -m "listenbrainz.listens_importer.lastfm"
user: "${LB_DOCKER_USER:-root}:${LB_DOCKER_GROUP:-root}"
depends_on:
- redis
- rabbitmq
- lb_db

websockets:
image: web
volumes:
Expand Down
7 changes: 7 additions & 0 deletions docker/rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ then
rm -f /etc/service/spotify_reader/down
fi

if [ "${CONTAINER_NAME}" = "listenbrainz-lastfm-reader-${DEPLOY_ENV}" ]
then
log Enabling last.fm importer
rm -f /etc/service/lastfm_importer/down
fi


if [ "${CONTAINER_NAME}" = "listenbrainz-spark-reader-${DEPLOY_ENV}" ]
then
log Enabling spark reader
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
template {
source = "/code/listenbrainz/consul_config.py.ctmpl"
destination = "/code/listenbrainz/listenbrainz/config.py"
}

exec {
command = ["run-lb-command", "python3", "-m", "listenbrainz.listens_importer.lastfm"]
splay = "5s"
reload_signal = "SIGHUP"
kill_signal = "SIGTERM"
kill_timeout = "30s"
}
17 changes: 17 additions & 0 deletions docker/services/lastfm_importer/lastfm_importer.finish
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

export service="lastfm-importer"

. /etc/lb-startup-common.sh


generate_message "$service" "$@"

log "$message"

send_sentry_message "$message"

if [ "$1" != "0" ]; then
log "Exited with non-0 status, sleeping 10 seconds"
sleep 10
fi
4 changes: 4 additions & 0 deletions docker/services/lastfm_importer/lastfm_importer.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

sleep 1
exec run-consul-template -config /etc/consul-template-lastfm-importer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ template {
}

exec {
command = ["run-lb-command", "python3", "-m", "listenbrainz.spotify_updater.spotify_read_listens"]
command = ["run-lb-command", "python3", "-m", "listenbrainz.listens_importer.spotify"]
splay = "5s"
reload_signal = "SIGHUP"
kill_signal = "SIGTERM"
Expand Down
3 changes: 2 additions & 1 deletion docs/users/api_usage_examples/set_latest_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
DEBUG = True
ROOT = 'http://localhost:8100' if DEBUG else 'https://api.listenbrainz.org'

def set_latest_import(timestamp, token, service="lastfm"):

def set_latest_import(timestamp, token, service="librefm"):
"""Sets the time of the latest import.
Args:
Expand Down
12 changes: 11 additions & 1 deletion frontend/css/brainzplayer.less
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,16 @@
stroke: #dedede !important;
color: #dedede !important;
}
&.music-service-icon {
max-width: 1.5em;
> svg {
// Youtube forces us to follow their branding guidelines to the letter,
// so we need to force a minimum height of 20px for the icon path inside the svg
// [poo emoji]
min-height: 26.7px;
vertical-align: middle;
}
}
}

.love,
Expand Down Expand Up @@ -348,7 +358,7 @@
transition: bottom 1s ease-in-out;
width: 100%;
max-width: 550px;
height: 500px;
height: min(500px, 100vh ~"-" @brainzplayer-height);
background-color: #f8f8f8;
border-top: 1px solid #ccc;
box-shadow: -6px -1px 10px rgba(0, 0, 0, 0.2);
Expand Down
4 changes: 2 additions & 2 deletions frontend/css/homepage.less
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@

@media (max-width: @screen-sm) {
.homepage-info {
bottom: 2.5em;
bottom: 4.5em;
}
.homepage-upper {
.listen-container {
Expand Down Expand Up @@ -459,7 +459,7 @@
top: 0;
}
.homepage-info {
bottom: 1.5em;
bottom: 4.5em;
color: @dark-grey;
max-width: 50%;
}
Expand Down
6 changes: 6 additions & 0 deletions frontend/css/music-services.less
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
@checkbox-size: 40px;

.music-service-selection {
button.music-service-option {
border: none;
background: none;
padding: 0;
width: 100%;
}
.music-service-option {
input[type="radio"] {
display: none;
Expand Down
57 changes: 39 additions & 18 deletions frontend/js/src/about/add-data/AddData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,19 @@ export default function AddData() {
, the web version of Tidal running in electron with Hi-Fi (High & Max)
support
</li>
<li>
<em>
<a href="https://tidal.com/">TIDAL</a>
</em>
, a cross-platform music player and streaming service:{" "}
<a href="https://github.com/uwu/neptune">
<code>neptune client mod</code>
</a>
+{" "}
<a href="https://github.com/Inrixia/neptune-plugins?tab=readme-ov-file#listenbrainz">
<code>ListenBrainz plugin</code>
</a>
</li>
<li>
<em>
<a href="https://www.videolan.org/vlc/">VLC</a>
Expand Down Expand Up @@ -214,7 +227,7 @@ export default function AddData() {
</em>
, a free and open source media center:{" "}
<a href="https://kodi.tv/addons/matrix/service.listenbrainz">
ListenBrainz add-on
<code>ListenBrainz add-on</code>
</a>
</li>
<li>
Expand Down Expand Up @@ -389,13 +402,9 @@ export default function AddData() {
ListenBrainz-SMP
</a>
</em>
, a{" "}
<em>
<a href="https://www.foobar2000.org/">Foobar2000</a>
</em>{" "}
plugin for submitting and retrieving playlists from ListenBrainz (+
Spotify), as well as retrieving recommendations or submitting feedback
on tracks.
, a Foobar2000 plugin for submitting and retrieving playlists from
ListenBrainz (+ Spotify). Can retrieve recommendations and submit
track feedback.
</li>
<li>
<em>
Expand All @@ -407,9 +416,17 @@ export default function AddData() {
<em>
<a href="https://www.foobar2000.org/">Foobar2000</a>
</em>{" "}
plugin for syncing local playlists (in multiple formats) with
ListenBrainz (+ Spotify). Tracks playlists changes and also allows to
resolve tracks with local content and YouTube links.
plugin for syncing local playlists with ListenBrainz (+ Spotify).
Tracks playlists changes and resolves tracks with local content and
YouTube links.
</li>
<li>
<em>
<a href="https://codeberg.org/scaglio/listenbrainz-scrobbler">
ListenBrainz macOS Scrobbler for Music.app
</a>
</em>
, a macOS Bash script to submit Music.app listens to ListenBrainz
</li>
<li>
<em>
Expand Down Expand Up @@ -437,15 +454,19 @@ export default function AddData() {
<ul>
<li>
<em>
<a href="https://github.com/regorxxx/Wrapped-SMP">Wrapped-SMP</a>
<a href="https://github.com/coopw1/BrainzBot">BrainzBot</a>
</em>
, a{" "}
, a Discord bot that can be user-run or added to your server. Showcase
what you&apos;re listening to, share charts, album grids, tag clouds,
and more.
</li>
<li>
<em>
<a href="https://www.foobar2000.org/">Foobar2000</a>
</em>{" "}
plugin for creating reports based on user listens similar to the one
found at Spotify. Suggested playlists use ListenBrainz recommendations
(without requiring listens upload to the server).
<a href="https://github.com/regorxxx/Wrapped-SMP">Wrapped-SMP</a>
</em>
, a Foobar2000 plugin that creates listening reports, similar to
Spotify&apos;s annual report. Can utilize ListenBrainz
recommendations.
</li>
</ul>

Expand Down
16 changes: 15 additions & 1 deletion frontend/js/src/album/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export type ListeningStats = {
export function getRelIconLink(relName: string, relValue: string) {
let icon;
let color;
let isYoutube = false;
switch (relName) {
case "streaming":
case "free streaming":
Expand All @@ -84,6 +85,7 @@ export function getRelIconLink(relName: string, relValue: string) {
case "youtube music":
icon = faYoutube;
color = dataSourcesInfo.youtube.color;
isYoutube = true;
break;
case "soundcloud":
icon = faSoundcloud;
Expand Down Expand Up @@ -130,6 +132,13 @@ export function getRelIconLink(relName: string, relValue: string) {
icon = faLink;
break;
}
let style = {};
if (isYoutube) {
// Youtube forces us to follow their branding guidelines to the letter,
// so we need to force a minimum height of 20px for the icon path inside the svg
// [poo emoji]
style = { height: "26.7px", width: "auto" };
}
return (
<a
key={relName}
Expand All @@ -139,7 +148,12 @@ export function getRelIconLink(relName: string, relValue: string) {
target="_blank"
rel="noopener noreferrer"
>
<FontAwesomeIcon icon={icon} fixedWidth color={color} />
<FontAwesomeIcon
icon={icon}
fixedWidth={!isYoutube}
color={color}
style={style}
/>
</a>
);
}
Expand Down
Loading

0 comments on commit 788f069

Please sign in to comment.