Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions userscript/sc-gate-dl.user.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name sc-gate-dl
// @namespace https://github.com/D3SOX/sc-gate-dl
// @version 1.10.4
// @version 1.10.5
// @description Add sc-gate-dl download controls and remember your position in the SoundCloud feed
// @author D3SOX
// @match https://soundcloud.com/*
Expand Down Expand Up @@ -592,9 +592,15 @@
}

let lastRecordedPlayingUrl = null;
let feedPlaybackActive = false;

function recordPlayingFeedTrack() {
if (!isFeedPage()) return;
if (!isFeedPage()) {
feedPlaybackActive = false;
lastRecordedPlayingUrl = null;
return;
}
if (!feedPlaybackActive) return;
Comment thread
D3SOX marked this conversation as resolved.
Outdated
const playing = document.querySelector(
'.playControls .playControl.playing, .playControls__play.playing, .playControls button[title^="Pause"], .playControls button[aria-label^="Pause"]',
);
Expand Down Expand Up @@ -2286,7 +2292,10 @@ a[${STORE_SERVICE_ATTR}] > button::after {
);
if (!playControl) return;
const card = playControl.closest(FEED_CARD_SELECTOR);
if (card) saveFeedCheckpointFromCard(card);
if (card) {
feedPlaybackActive = true;
saveFeedCheckpointFromCard(card);
}
},
true,
);
Expand Down
15 changes: 15 additions & 0 deletions webui/src/components/App.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/// <reference types="bun" />

import { describe, expect, test } from 'bun:test';
import { cleanPromoTags } from './App';

describe('cleanPromoTags', () => {
test('removes a bracketed premiere prefix', () => {
expect(cleanPromoTags('[PREMIERE] Artist - Track')).toBe(
'Artist - Track',
);
expect(cleanPromoTags('[PREMIERE]: Artist - Track')).toBe(
'Artist - Track',
);
});
});
29 changes: 24 additions & 5 deletions webui/src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,15 @@ function notifyParent(
/** Promo fluff often glued onto SoundCloud / gate titles. */
const PROMO_TAG = String.raw`free\s*d(?:own)?l(?:oad)?s?|free[\s._-]*dl|freedl|out\s*now|premiere|exclusive`;

function cleanPromoTags(value: string): string {
export function cleanPromoTags(value: string): string {
if (!value) return value;

let result = value;
result = result.replace(
new RegExp(String.raw`\s*[\[\(\{]\s*(?:${PROMO_TAG})\s*[\]\)\}]`, 'gi'),
new RegExp(
String.raw`\s*[\[\(\{]\s*(?:${PROMO_TAG})\s*[\]\)\}]\s*(?:[-–—|/:·•]+\s*)?`,
'gi',
),
' ',
);
result = result.replace(
Expand Down Expand Up @@ -412,7 +415,7 @@ export default function App() {

// Start download process
const startDownload = useCallback(
async (jobId: string) => {
async (jobId: string, retryBrowserMode?: BrowserMode) => {
cancelRequestedRef.current = false;
setStep('gate');
setJob((prev) => ({
Expand All @@ -433,7 +436,7 @@ export default function App() {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
browserMode,
browserMode: retryBrowserMode ?? browserMode,
Comment thread
D3SOX marked this conversation as resolved.
Outdated
}),
});

Expand Down Expand Up @@ -1029,6 +1032,22 @@ export default function App() {
<div className="error-banner">
<span className="error-icon">!</span>
<span>{job.error}</span>
{job.jobId && job.progress?.stage === 'error'
? availableBrowserModes
.filter((mode) => mode !== browserMode)
.map((mode) => (
<button
type="button"
key={mode}
onClick={() => {
updateBrowserMode(mode);
void startDownload(job.jobId as string, mode);
}}
>
Retry with {BROWSER_MODE_LABELS[mode]}
</button>
))
: null}
Comment thread
D3SOX marked this conversation as resolved.
<button
type="button"
onClick={() => setJob((prev) => ({ ...prev, error: null }))}
Expand Down Expand Up @@ -1448,7 +1467,7 @@ export default function App() {
type="button"
className="btn-secondary btn-auto-cleanup"
disabled={isLoading}
title="Remove promo tags like [FREE DL] and duplicate Artist - / - Artist from the title"
title="Remove promo tags like [FREE DL] or [PREMIERE] and duplicate Artist - / - Artist from the title"
onClick={() =>
setMetadata((prev) => cleanMetadataFields(prev))
}
Expand Down