Skip to content

Commit

Permalink
add support for text lists of urls
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Jul 14, 2024
1 parent 14ec9d8 commit 8226d5d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ interface SearchResult extends PlaylistVideo {
size?: string | number;
seeders?: string;
magnet?: string;
type: string;
type: 'youtube' | 'file' | 'magnet';
url: string;
name: string;
duration: number;
Expand Down
2 changes: 1 addition & 1 deletion src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class ComboBox extends React.Component<ComboBoxProps> {
items = await getMediaPathResults(this.props.mediaPath, '');
}
if (query) {
let type = 'file';
let type: SearchResult['type'] = 'file';
if (isYouTube(query)) {
type = 'youtube';
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Settings/SettingsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export const SettingsTab = ({
toggle={false}
icon={'folder'}
name={`Set Room Media Source`}
description="Set a media source URL with files to replace the default examples. Supports S3-compatible buckets and YouTube playlists."
description="Set a media source URL with files to replace the default examples. Supports S3 buckets, YouTube playlists, or a text list of URLs."
content={
<Input
value={mediaPath ?? ''}
Expand Down
7 changes: 7 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,13 @@ export async function getMediaPathResults(
);
const data = await response.json();
return data;
} else {
// Assume it's a text list of URLs
const response = await window.fetch(mediaPath);
const text = await response.text();
results = text
.split('\n')
.map((line) => ({ url: line, name: line, duration: 0, type: 'file' }));
}
results = results.filter(
(option: SearchResult) =>
Expand Down

0 comments on commit 8226d5d

Please sign in to comment.