Skip to content

Add delete-karakeep-videos function for selective cleanup of orphaned videos#31

Draft
Copilot wants to merge 5 commits intomasterfrom
copilot/delete-karakeep-videos-function
Draft

Add delete-karakeep-videos function for selective cleanup of orphaned videos#31
Copilot wants to merge 5 commits intomasterfrom
copilot/delete-karakeep-videos-function

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 2, 2026

Implementation Complete for delete-karakeep-videos Function

  • Analyze the existing download-karakeep-videos.zsh function structure
  • Create new delete-karakeep-videos.zsh function with the following features:
    • Download the listen list from karakeep (reuse API logic)
    • Check which videos are downloaded but no longer in karakeep
    • Display a numbered list of files that can be deleted
    • Prompt user to enter numbers (comma or space separated) of videos to delete
    • Delete only the selected videos
  • Follow the same code style and structure as existing function
  • Pass shellcheck validation
  • Address code review feedback
  • Fix video matching logic:
    • Use hybrid approach: fast O(1) lookup + fallback O(n) search
    • Match video IDs same way as download function (wildcard matching)
    • Add comprehensive verbose debugging output
  • Test matching logic with edge cases
  • Run security scan

Bug Fix

Fixed critical bug where videos in Karakeep were incorrectly flagged for deletion. The function now uses a hybrid matching approach:

  1. Fast O(1) lookup by extracting video ID from filename pattern
  2. Fallback wildcard search if extraction fails (handles edge cases)

This ensures compatibility with how the download function detects existing videos.

Original prompt

This section details on the original issue you should resolve

<issue_title>Remove downloaded files</issue_title>
<issue_description>I have a zsh function, that currently calls karakeep, downloads my listen list and downloads every video, that's not already downloaded.

I need another function delete-karakeep-videos that is doing the opposite:

  • Download the listen list from karakeep
  • Check which videos are downloaded, but no longer in the karakeep app

It should not blindly delete them, but give a numbered list of the files names and ask me, which numbers it should delete.

If you don't have a better idea, I want to insert the number comma or space separated into stdin when the function is asking.

Then it should delete only the mentioned videos</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 2, 2026 14:11
Co-authored-by: Eckii24 <35373554+Eckii24@users.noreply.github.com>
Co-authored-by: Eckii24 <35373554+Eckii24@users.noreply.github.com>
Co-authored-by: Eckii24 <35373554+Eckii24@users.noreply.github.com>
Copilot AI changed the title [WIP] Add function to delete karakeep videos based on listen list Add delete-karakeep-videos function for selective cleanup of orphaned videos Jan 2, 2026
Copilot AI requested a review from Eckii24 January 2, 2026 14:16
@Eckii24
Copy link
Copy Markdown
Owner

Eckii24 commented Jan 2, 2026

It does not work at the moment. It is detecting videos for deletion, that are actually part of karakeep!!! @copilot please check again

Co-authored-by: Eckii24 <35373554+Eckii24@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 2, 2026

It does not work at the moment. It is detecting videos for deletion, that are actually part of karakeep!!! @copilot please check again

Fixed in commit 5df072c. The issue was that the video ID matching logic wasn't handling all edge cases. The function now uses a hybrid approach:

  1. Fast path: O(1) lookup by extracting video ID from the filename pattern %(title)s-%(id)s.%(ext)s
  2. Fallback path: Wildcard search if extraction fails, matching the same logic used by the download function

This ensures videos in Karakeep are correctly identified. You can use the -v flag to see detailed debug output showing which video IDs are found in Karakeep and how each file is matched.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove downloaded files

2 participants