Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
19 changes: 15 additions & 4 deletions .github/workflows/coverage-badges.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
name: Update Coverage Badges

on:
push:
branches: [ main ]
workflow_run:
workflows: ["Production Release"]
types: [completed]
branches: [main]
workflow_dispatch:

concurrency:
group: coverage-badges-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: write

jobs:
update-badges:
name: Update Coverage Badges
runs-on: ubuntu-latest
# Skip if commit message contains [skip ci]
if: "!contains(github.event.head_commit.message, '[skip ci]')"
# Run on workflow_dispatch or when Production Release succeeds (skip if commit has [skip ci])
if: >
github.event_name == 'workflow_dispatch' ||
(github.event.workflow_run.conclusion == 'success' &&
!contains(github.event.workflow_run.head_commit.message, '[skip ci]'))

steps:
- name: Checkout code
Expand Down Expand Up @@ -131,6 +140,8 @@ jobs:
if [[ -n $(git status --porcelain) ]]; then
git add README.md .github/badges/
git commit -m "chore: update coverage badges [skip ci]"
# Pull latest changes before pushing to handle any commits made during workflow run
git pull --rebase origin main
git push
else
echo "No changes to coverage badges"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Avatar, Box, Card, CardActionArea, CardContent, Chip, IconButton, Toolt
import DeleteIcon from '@mui/icons-material/Delete';
import ImageIcon from '@mui/icons-material/Image';
import { Channel } from '../../../types/Channel';
import { QualityChip, AutoDownloadChips, DurationFilterChip, TitleFilterChip } from './chips';
import { QualityChip, AutoDownloadChips, DurationFilterChip, TitleFilterChip, DownloadFormatConfigIndicator } from './chips';
import FolderIcon from '@mui/icons-material/Folder';

interface ChannelCardProps {
Expand Down Expand Up @@ -223,7 +223,8 @@ interface CardDetailsProps {
const CardDetails: React.FC<CardDetailsProps> = ({ channel, isMobile, onRegexClick }) => {
return (
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1.75 }}>
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5, alignItems: 'center' }}>
<DownloadFormatConfigIndicator audioFormat={channel.audio_format} />
<AutoDownloadChips
availableTabs={channel.available_tabs}
autoDownloadTabs={channel.auto_download_enabled_tabs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from '@mui/material';
import DeleteIcon from '@mui/icons-material/Delete';
import { Channel } from '../../../types/Channel';
import { SubFolderChip, QualityChip, AutoDownloadChips, DurationFilterChip, TitleFilterChip } from './chips';
import { SubFolderChip, QualityChip, AutoDownloadChips, DurationFilterChip, TitleFilterChip, DownloadFormatConfigIndicator } from './chips';

interface ChannelListRowProps {
channel: Channel;
Expand Down Expand Up @@ -103,6 +103,7 @@ const ChannelListRow: React.FC<ChannelListRowProps> = ({
</Tooltip>
</Box>
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.75, alignItems: 'center' }}>
<DownloadFormatConfigIndicator audioFormat={channel.audio_format} />
<AutoDownloadChips
availableTabs={channel.available_tabs}
autoDownloadTabs={channel.auto_download_enabled_tabs}
Expand Down Expand Up @@ -184,6 +185,7 @@ const ChannelListRow: React.FC<ChannelListRowProps> = ({
alignItems: 'center',
}}
>
<DownloadFormatConfigIndicator audioFormat={channel.audio_format} />
<AutoDownloadChips
availableTabs={channel.available_tabs}
autoDownloadTabs={channel.auto_download_enabled_tabs}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ jest.mock('../chips', () => ({
onClick: (e: any) => onRegexClick(e, titleFilterRegex),
}, `Title Filter: ${titleFilterRegex}`);
},
DownloadFormatConfigIndicator: function MockDownloadFormatConfigIndicator({ audioFormat }: any) {
const React = require('react');
return React.createElement('div', {
'data-testid': 'download-format-config-indicator',
'data-audio-format': audioFormat,
}, 'Format');
},
}));

describe('ChannelCard Component', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ jest.mock('../chips', () => ({
'Title Filter'
);
},
DownloadFormatConfigIndicator: function MockDownloadFormatConfigIndicator({ audioFormat }: any) {
const React = require('react');
return React.createElement(
'div',
{
'data-testid': 'download-format-config-indicator',
'data-audio-format': audioFormat,
},
'Format'
);
},
}));

describe('ChannelListRow', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import { Box, Tooltip } from '@mui/material';
import { MovieOutlined as VideoIcon, AudiotrackOutlined as AudioIcon } from '@mui/icons-material';

interface DownloadFormatConfigIndicatorProps {
audioFormat: string | null | undefined;
}

const DownloadFormatConfigIndicator: React.FC<DownloadFormatConfigIndicatorProps> = ({
audioFormat,
}) => {
// Determine which icons to show based on audio_format setting:
// - null or undefined: video only (default)
// - 'video_mp3': both video and mp3
// - 'mp3_only': mp3 only
const showVideo = !audioFormat || audioFormat === 'video_mp3';
const showAudio = audioFormat === 'video_mp3' || audioFormat === 'mp3_only';

return (
<Box
sx={{
display: 'inline-flex',
alignItems: 'center',
gap: 0.25,
}}
data-testid="download-format-config-indicator"
>
{showVideo && (
<Tooltip title="Video downloads" arrow placement="top" enterTouchDelay={0}>
<VideoIcon
data-testid="video-format-icon"
sx={{
fontSize: '1rem',
color: 'primary.main',
}}
/>
</Tooltip>
)}
{showAudio && (
<Tooltip title="MP3 downloads" arrow placement="top" enterTouchDelay={0}>
<AudioIcon
data-testid="audio-format-icon"
sx={{
fontSize: '1rem',
color: 'secondary.main',
}}
/>
</Tooltip>
)}
</Box>
);
};

export default DownloadFormatConfigIndicator;
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import DownloadFormatConfigIndicator from '../DownloadFormatConfigIndicator';
import { renderWithProviders } from '../../../../../test-utils';

describe('DownloadFormatConfigIndicator', () => {
test('shows only video icon when audioFormat is null (default)', () => {
renderWithProviders(<DownloadFormatConfigIndicator audioFormat={null} />);

expect(screen.getByTestId('video-format-icon')).toBeInTheDocument();
expect(screen.queryByTestId('audio-format-icon')).not.toBeInTheDocument();
});

test('shows only video icon when audioFormat is undefined', () => {
renderWithProviders(<DownloadFormatConfigIndicator audioFormat={undefined} />);

expect(screen.getByTestId('video-format-icon')).toBeInTheDocument();
expect(screen.queryByTestId('audio-format-icon')).not.toBeInTheDocument();
});

test('shows both video and audio icons when audioFormat is video_mp3', () => {
renderWithProviders(<DownloadFormatConfigIndicator audioFormat="video_mp3" />);

expect(screen.getByTestId('video-format-icon')).toBeInTheDocument();
expect(screen.getByTestId('audio-format-icon')).toBeInTheDocument();
});

test('shows only audio icon when audioFormat is mp3_only', () => {
renderWithProviders(<DownloadFormatConfigIndicator audioFormat="mp3_only" />);

expect(screen.queryByTestId('video-format-icon')).not.toBeInTheDocument();
expect(screen.getByTestId('audio-format-icon')).toBeInTheDocument();
});

test('renders container with correct testid', () => {
renderWithProviders(<DownloadFormatConfigIndicator audioFormat={null} />);

expect(screen.getByTestId('download-format-config-indicator')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export { default as QualityChip } from './QualityChip';
export { default as AutoDownloadChips } from './AutoDownloadChips';
export { default as DurationFilterChip } from './DurationFilterChip';
export { default as TitleFilterChip } from './TitleFilterChip';
export { default as DownloadFormatConfigIndicator } from './DownloadFormatConfigIndicator';
3 changes: 3 additions & 0 deletions client/src/components/ChannelPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function ChannelPage({ token }: ChannelPageProps) {
const handleSettingsSaved = (updated: {
sub_folder: string | null;
video_quality: string | null;
audio_format: string | null;
min_duration: number | null;
max_duration: number | null;
title_filter_regex: string | null;
Expand All @@ -41,6 +42,7 @@ function ChannelPage({ token }: ChannelPageProps) {
...prev,
sub_folder: updated.sub_folder,
video_quality: updated.video_quality,
audio_format: updated.audio_format,
min_duration: updated.min_duration,
max_duration: updated.max_duration,
title_filter_regex: updated.title_filter_regex,
Expand Down Expand Up @@ -331,6 +333,7 @@ function ChannelPage({ token }: ChannelPageProps) {
channelAutoDownloadTabs={channel?.auto_download_enabled_tabs}
channelId={channel_id || undefined}
channelVideoQuality={channel?.video_quality || null}
channelAudioFormat={channel?.audio_format || null}
/>

{channel && channel_id && (
Expand Down
46 changes: 40 additions & 6 deletions client/src/components/ChannelPage/ChannelSettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface ChannelSettings {
min_duration: number | null;
max_duration: number | null;
title_filter_regex: string | null;
audio_format: string | null;
}

interface FilterPreviewVideo {
Expand Down Expand Up @@ -91,14 +92,16 @@ function ChannelSettingsDialog({
video_quality: null,
min_duration: null,
max_duration: null,
title_filter_regex: null
title_filter_regex: null,
audio_format: null
});
const [originalSettings, setOriginalSettings] = useState<ChannelSettings>({
sub_folder: null,
video_quality: null,
min_duration: null,
max_duration: null,
title_filter_regex: null
title_filter_regex: null,
audio_format: null
});
const [subfolders, setSubfolders] = useState<string[]>([]);
const [loading, setLoading] = useState(true);
Expand Down Expand Up @@ -174,7 +177,8 @@ function ChannelSettingsDialog({
video_quality: settingsData.video_quality || null,
min_duration: settingsData.min_duration || null,
max_duration: settingsData.max_duration || null,
title_filter_regex: settingsData.title_filter_regex || null
title_filter_regex: settingsData.title_filter_regex || null,
audio_format: settingsData.audio_format || null
};
setSettings(loadedSettings);
setOriginalSettings(loadedSettings);
Expand Down Expand Up @@ -229,7 +233,8 @@ function ChannelSettingsDialog({
video_quality: settings.video_quality || null,
min_duration: settings.min_duration,
max_duration: settings.max_duration,
title_filter_regex: settings.title_filter_regex || null
title_filter_regex: settings.title_filter_regex || null,
audio_format: settings.audio_format || null
})
});

Expand All @@ -256,7 +261,8 @@ function ChannelSettingsDialog({
video_quality: result?.settings?.video_quality ?? settings.video_quality ?? null,
min_duration: result?.settings?.min_duration ?? settings.min_duration ?? null,
max_duration: result?.settings?.max_duration ?? settings.max_duration ?? null,
title_filter_regex: result?.settings?.title_filter_regex ?? settings.title_filter_regex ?? null
title_filter_regex: result?.settings?.title_filter_regex ?? settings.title_filter_regex ?? null,
audio_format: result?.settings?.audio_format ?? settings.audio_format ?? null
};

setSettings(updatedSettings);
Expand Down Expand Up @@ -294,7 +300,8 @@ function ChannelSettingsDialog({
settings.video_quality !== originalSettings.video_quality ||
settings.min_duration !== originalSettings.min_duration ||
settings.max_duration !== originalSettings.max_duration ||
settings.title_filter_regex !== originalSettings.title_filter_regex;
settings.title_filter_regex !== originalSettings.title_filter_regex ||
settings.audio_format !== originalSettings.audio_format;
};

const handlePreviewFilter = async () => {
Expand Down Expand Up @@ -415,6 +422,33 @@ function ChannelSettingsDialog({
Effective channel quality: {effectiveQualityDisplay}.
</Typography>

<FormControl fullWidth sx={{ mt: 1 }}>
<InputLabel id="audio-format-label" shrink>Download Type</InputLabel>
<Select
labelId="audio-format-label"
value={settings.audio_format || ''}
label="Download Type"
onChange={(e) => setSettings({
...settings,
audio_format: e.target.value || null
})}
displayEmpty
notched
>
<MenuItem value="">
<em>Video Only (default)</em>
</MenuItem>
<MenuItem value="video_mp3">Video + MP3</MenuItem>
<MenuItem value="mp3_only">MP3 Only</MenuItem>
</Select>
</FormControl>

{settings.audio_format && (
<Typography variant="caption" color="text.secondary">
MP3 files are saved at 192kbps in the same folder as videos.
</Typography>
)}

<Alert severity="info" sx={{ mb: 2 }}>
<Typography variant="body2" sx={{ fontWeight: 'bold', mb: 1 }}>
Subfolder Organization
Expand Down
Loading