diff --git a/public/locales/en.json b/public/locales/en.json index 342c5449..89c723af 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", + "albumRemovalPattern": "Removable text pattern from every track name", + "albumRemovalPatternDescription": "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 a00d5d7f..35c7033c 100644 --- a/public/locales/it.json +++ b/public/locales/it.json @@ -20,6 +20,8 @@ "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", + "albumRemovalPattern": "Pattern removibile da ogni nome di canzone", + "albumRemovalPatternDescription": "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.tsx b/src/components/ScrobbleItem.tsx index 7622a75d..82bbde8a 100644 --- a/src/components/ScrobbleItem.tsx +++ b/src/components/ScrobbleItem.tsx @@ -34,6 +34,7 @@ import { useSettings } from 'hooks/useSettings'; interface ScrobbleItemProps { scrobble: Scrobble; + scrobbleRemovalPattern?: string; compact?: boolean; hideArtist?: boolean; muteArtist?: boolean; @@ -48,6 +49,7 @@ interface ScrobbleItemProps { export default function ScrobbleItem({ scrobble, + scrobbleRemovalPattern = '', compact = false, hideArtist = false, muteArtist = false, @@ -86,6 +88,7 @@ export default function ScrobbleItem({ enqueueScrobble(dispatch)([ { ...scrobble, + title: scrobbleRemovalPattern !== '' ? scrobble.title.replaceAll(scrobbleRemovalPattern, '').trim() : scrobble.title, timestamp: useOriginalTimestamp ? scrobble.timestamp : new Date(), }, ]); diff --git a/src/components/ScrobbleList.tsx b/src/components/ScrobbleList.tsx index b7d253ff..50360306 100644 --- a/src/components/ScrobbleList.tsx +++ b/src/components/ScrobbleList.tsx @@ -16,6 +16,7 @@ interface ScrobbleListProps { onSelect?: (scrobble: any) => void; selected?: Set; scrobbles?: any[]; + scrobblesRemovalPattern?: string; } export default function ScrobbleList({ @@ -28,6 +29,7 @@ export default function ScrobbleList({ onSelect, selected, scrobbles = [], + scrobblesRemovalPattern, }: ScrobbleListProps) { const { cloneFn, setCloneFn } = useContext(ScrobbleCloneContext); let albumHasVariousArtists = !isAlbum; @@ -52,6 +54,7 @@ export default function ScrobbleList({ return ( (() => getAmznLink(albumInfo?.artist, albumInfo?.name), [albumInfo]); const [canScrobble, setCanScrobble] = useState(true); // ToDo: simplify customTimestamp + useCustomTimestamp const [customTimestamp, setCustomTimestamp] = useState(new Date()); const [useCustomTimestamp, setUseCustomTimestamp] = useState(false); + const [useRemovalPattern, setUseRemovalPattern] = useState(''); const [selectedTracks, setSelectedTracks] = useState>(new Set()); const [totalDuration, setTotalDuration] = useState(0); const albumHasTracks = tracks && tracks.length > 0; @@ -89,11 +91,19 @@ export default function Tracklist({ albumInfo, tracks }: { albumInfo: Album | nu setSelectedTracks(newSet); }; + const toggleRemovalPatternCopy = () => { + setShowRemovalPatternCopy(!showRemovalPatternCopy); + }; + const handleTimestampChange = (newTimestamp) => { setCustomTimestamp(newTimestamp); setCanScrobble(true); }; + const handleRemovalPatternChange = (event) => { + setUseRemovalPattern(event.target.value); + }; + const scrobbleSelectedTracks = () => { const userHasNotSelectedTracks = selectedTracks.size < 1; const timestampCalculationSubstractsTime = !useCustomTimestamp; @@ -112,6 +122,7 @@ export default function Tracklist({ albumInfo, tracks }: { albumInfo: Album | nu .reduce((result, track) => { const newTrack = { ...track, + title: useRemovalPattern !== '' ? track.title.replaceAll(useRemovalPattern, '').trim() : track.title, album: albumInfo?.name || '', albumArtist: albumInfo?.artist || '', timestamp: rollingTimestamp, @@ -247,11 +258,47 @@ export default function Tracklist({ albumInfo, tracks }: { albumInfo: Album | nu noMenu analyticsEventForScrobbles="Scrobble individual album song" scrobbles={tracks || []} + scrobblesRemovalPattern={useRemovalPattern} onSelect={toggleSelectedTrack} selected={selectedTracks} > + +
+ +
+ + +
+
+ +
+
+ + + +
+
+
); }