diff --git a/public/locales/en.json b/public/locales/en.json index 496d4f1..30e88e5 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -18,8 +18,10 @@ "scrobbleSelected": "Scrobble selected", "findAlbumCopy": "Enter an album or artist name", "customTimestamp": "Custom timestamp", - "albumTimestampLogicDescription": "Scrobbling tracks \"now\" will scrobble the last track at the current time, backdating the previous ones accordingly (as if you had just finished listening). The \"custom timestamp\" will define the timestamp of the first track and add time to the following tracks from there (i.e. you specify the time you started listening to this album)", + "albumTimestampLogicDescription": "Scrobbling tracks \"now\" will scrobble the last track at the current time, backdating the previous ones accordingly (as if you had just finished listening). The \"custom timestamp\" will define the timestamp of the first track and add time to the following tracks from there (i.e. you specify the time you started listening to this album).", "albumArtist": "Album artist", + "filter": "Filter", + "albumCleanupPatternDescription": "Some albums tracks are displayed with some repeated text (i.e. Demo, Live, Remastered, ...). These are patterns that could be considered annoying to scrobble, for some users. Set the full pattern (including paranthesis, dashes, ...) that you would like to be removed, from the track names.", "history": "History", "yourProfile": "Your profile", "yourHistory": "Your history", diff --git a/public/locales/it.json b/public/locales/it.json index e2f3183..33f62df 100644 --- a/public/locales/it.json +++ b/public/locales/it.json @@ -20,6 +20,7 @@ "customTimestamp": "Timestamp personalizzato", "albumTimestampLogicDescription": "Scrobblando le canzoni \"adesso\" scrobblerà l'ultima canzone in questo momento, anticipando relativamente le precedenti (come se avessi appena finito di ascoltarle). Il \"timestamp personalizzato\" definirà il timestamp di ascolto della prima traccia ed agginguerà il relativo tempo alle canzoni successive (come se avessi iniziato ad ascoltare l'album nel timestamp selezionato)", "albumArtist": "Artista di un Album", + "albumCleanupPatternDescription": "Alcune canzoni di album sono visualizzate con un certo testo ripetuto (ad esempio Demo, Live, Remastered, ...). Questi sono pattern che potrebbero risultare fastidiosi da scrobblare, per alcuni utenti. Imposta il pattern completo (incluse parentesi, trattini, ...) che desideri venga rimosso dai nomi delle canzoni.", "history": "Storico", "yourProfile": "Tuo profilo", "yourHistory": "Tuo storico", diff --git a/src/components/ScrobbleItem.css b/src/components/ScrobbleItem.css index dbf4eac..3ece4ee 100644 --- a/src/components/ScrobbleItem.css +++ b/src/components/ScrobbleItem.css @@ -97,3 +97,8 @@ padding-left: 1.15rem; padding-right: 1.15rem; } + +.scrobbled-item del { + color: var(--bs-secondary-color) !important; + background-color: rgba(255, 32, 0, 0.2); +} diff --git a/src/components/ScrobbleItem.tsx b/src/components/ScrobbleItem.tsx index 70c86af..ec47dda 100644 --- a/src/components/ScrobbleItem.tsx +++ b/src/components/ScrobbleItem.tsx @@ -6,7 +6,7 @@ import { get } from 'lodash-es'; import { enqueueScrobble } from 'store/actions/scrobbleActions'; import { Button, Input, Dropdown, DropdownToggle, DropdownMenu, DropdownItem, FormGroup, Label } from 'reactstrap'; -import { useState } from 'react'; +import { Fragment, useState } from 'react'; import { LazyLoadImage } from 'react-lazy-load-image-component'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { @@ -22,6 +22,7 @@ import { } from '@fortawesome/free-solid-svg-icons'; import { faClock, faCopy } from '@fortawesome/free-regular-svg-icons'; import { getAmznLink } from 'Constants'; +import { breakStringUsingPattern, cleanTitleWithPattern } from 'domains/scrobbleAlbum/CleanupContext'; import type { Scrobble } from 'utils/types/scrobble'; @@ -31,6 +32,7 @@ import { formatDuration, formatScrobbleTimestamp } from 'utils/datetime'; interface ScrobbleItemProps { scrobble: Scrobble; + cleanupPattern?: RegExp; compact?: boolean; hideArtist?: boolean; muteArtist?: boolean; @@ -45,6 +47,7 @@ interface ScrobbleItemProps { export default function ScrobbleItem({ scrobble, + cleanupPattern, compact = false, hideArtist = false, muteArtist = false, @@ -83,6 +86,7 @@ export default function ScrobbleItem({ enqueueScrobble(dispatch)([ { ...scrobble, + title: cleanTitleWithPattern(scrobble.title, cleanupPattern), timestamp: useOriginalTimestamp ? scrobble.timestamp : new Date(), }, ]); @@ -100,6 +104,13 @@ export default function ScrobbleItem({ return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(); }); }; + + const strikethroughMatch = (text: string, pattern?: RegExp) => { + return breakStringUsingPattern(text, pattern).map(({ value, isMatch }, index) => ( + {!isMatch ? value : {value}} + )); + }; + let albumArt; let errorMessage; let rightSideContent; @@ -172,18 +183,23 @@ export default function ScrobbleItem({ ); + const formattedTitle = strikethroughMatch(properCase(scrobble.title, true), cleanupPattern); if (!hideArtist) { if (muteArtist) { songFullTitle = ( <> - {properCase(scrobble.title, true)} {properCase(scrobble.artist)} + {formattedTitle} {properCase(scrobble.artist)} ); } else { - songFullTitle = `${properCase(scrobble.artist)} - ${properCase(scrobble.title, true)}`; + songFullTitle = ( + <> + {properCase(scrobble.artist)} - {formattedTitle} + + ); } } else { - songFullTitle = properCase(scrobble.title, true); + songFullTitle = formattedTitle; } const scrobbleItemInputId = `ScrobbleItem-checkbox-${scrobble.uuid}`; @@ -201,7 +217,7 @@ export default function ScrobbleItem({ // FULL view songInfo = ( <> - {songFullTitle} + {songFullTitle}