fronzbot / blinkpy

A Python library for the Blink Camera system

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add 'delete' and 'delete all' endpoints to library

ossumpossum opened this issue · comments

It would be quite helpful to have the delete and deleteall endpoints implemented in order to effectively manage storage by being able to delete either specific videos or all the videos currently stored.

maybe add a parameter to download_videos(), which deletes a video after a successful (!) download

Just as an update, I took a look at this but there's more information needed in order to implement this. Performing a POST /api/v1/accounts/{AccountID}/media/delete results in the following response: {'message': 'Invalid Media List Format', 'code': 706}. I tried simple stuff like sending data in a format like {"media": [clips]} but always got the same response.

So this will remain on the to-do list. I was hoping it would be an easy add 😞

Here is the relevant endpoint. If I have some time this weekend, I will give it a shot.

  Call<Object> deleteMediaCall(@Body MediaIdListBody paramMediaIdListBody);

  @SerializedName("lv_discard")
  private final Boolean localViewDiscard;
  
  @SerializedName("media_list")
  private final List<Long> mediaIdList;
  
  public MediaIdListBody(Boolean paramBoolean, List<Long> paramList) {
    this.localViewDiscard = paramBoolean;
    this.mediaIdList = paramList;
  }

can we delete videeos before a particlular datetime from cloud and sync module with this. for ex -

  1. i want to delete vidoes before "2022-11-23 00:00" from cloud
  2. i want to delete vidoes before "2022-11-23 00:00" from sync module 2

will we able to both 1) and 2) from this ?

commented

@fronzbot @ruby-dev will it be possible ?

I think we have solved for item 2:

async def delete_video(self, blink, max_retries=4) -> bool:
"""Delete video from sync module."""
delete_url = blink.urls.base_url + self.url()
delete_url = delete_url.replace("request", "delete")
for retry in range(max_retries):
delete = await api.http_post(
blink, delete_url, json=False
) # Delete the video
if delete.status == 200:
return True
seconds = backoff_seconds(retry=retry, default_time=3)
_LOGGER.debug("[retry=%d] Retrying in %d seconds", retry + 1, seconds)
await asyncio.sleep(seconds)
return False

You can poll the videos, create a list and delete them with this function.