Skip to content

Commit

Permalink
feat: add ability to skip videos shorter than X seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
thevops committed Sep 18, 2024
1 parent cea20e8 commit 49c6915
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ prompt: |
<summary>
Słowa kluczowe: <keywords>
skip_videos_shorter_than: 120 # seconds
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface ConfigSchema {
raindrop_source_collection_id: string;
raindrop_target_collection_id: string;
prompt: string;
skip_videos_shorter_than: number;

[key: string]: any;
}
Expand All @@ -23,6 +24,7 @@ function validateConfig(config: ConfigSchema) {
"raindrop_source_collection_id",
"raindrop_target_collection_id",
"prompt",
"skip_videos_shorter_than",
];

for (const field of requiredFields) {
Expand Down
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ async function main() {
const [title, channel, duration, upload_date] =
await getVideoDetails(videoId);

// Duration format: HH:MM:SS
// Convert duration to seconds
const duration_parts = duration.split(":");
const seconds = Number(duration_parts[0]) * 3600 +
Number(duration_parts[1]) * 60 +
Number(duration_parts[2]);
// Skip videos shorter than X seconds
if (seconds < Config.skip_videos_shorter_than) {
logger.info(`Skipping video shorter than ${Config.skip_videos_short_than} seconds: ${link}`);
return;
}

// Get transcript from YouTube
const transcript = await getTranscript(videoId);

Expand Down

0 comments on commit 49c6915

Please sign in to comment.