Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

download_videos using "since" downloads videos before the since time #604

Open
jakekausler opened this issue Jul 14, 2022 · 8 comments
Open
Labels
blink-api-issue There is an issue with the Blink API that needs to be addressed before the issue can be solved bug There is an issue causing unexpected results help-wanted Assistance required due to lack of resources for testing or complexity

Comments

@jakekausler
Copy link

When I use the download_videos function and provide a since time of, for example, "2022/07/14 04:00", I get videos going back to "2022/17/13 22:00". I'm trying to grab all the videos from a day (I'm 4 hours behind UTC), and don't want to have to redundantly download and delete videos. Is this a known issue?

@ruby-dev
Copy link
Contributor

@jakekausler Are you using UTC in the since time? It looks like the lib is converting to epoch time but doesnt account for Timezone as it doesn't know what timezone the since time is in.

parsed_datetime = parse(since, fuzzy=True)
since_epochs = parsed_datetime.timestamp()

@jakekausler
Copy link
Author

Yeah I convert to utc first, so I don't think that's it

@ruby-dev
Copy link
Contributor

ruby-dev commented Jul 16, 2022

The library is taking the input and calling the API directly, so I would venture to guess it has something to do with the way the remote API handles the dates/times.

@fronzbot
Copy link
Owner

I would venture to guess it has something to do with the way the remote API handles the dates/times.

Yep, this exactly. It took me a lot of trial and error to get something to relatively consistently work with Blink's servers as it wasn't clear how they were doing date/time conversion. If I'm remembering correctly, there were also differences based on region you're in (US, Europe, etc).

What I have in there may not be the best approach, it's just what made sense to me (and worked for me) at the time I made it. Things may have changed or there may be a more robust implementation and would love to make this more bullet proof if possible

@ruby-dev
Copy link
Contributor

@fronzbot It does look like maybe we can pass in an offset timestamp possibly instead of a unix timestamp according to this API string. I haven't tried it yet so not sure what the results would be.

  @GET("https://rest-{tier}.immedia-semi.com/api/v2/accounts/{injected_account_id}/media/changed")
  Call<ChangedMedia> getChangedMedia(@Query("since") OffsetDateTime paramOffsetDateTime, @Query("page") int paramInt);

@ruby-dev
Copy link
Contributor

I have tried all kinds of date formats, api options, header options and nothing seems to change the response. It looks like it is downloading the same video files no matter the date. Even using the unix timestamp it is downloading all the videos. I also did some snooping through a proxy and the iOS app is doing the same. So I would say the API endpoint here is the cause and until it is fixed, there is not much we can do.

@fronzbot fronzbot added blink-api-issue There is an issue with the Blink API that needs to be addressed before the issue can be solved bug There is an issue causing unexpected results help-wanted Assistance required due to lack of resources for testing or complexity labels Jul 26, 2022
@sissiwup
Copy link

Hello, is it not possible to check the Date in _parse_downloaded_items?
Cameraname and deleted is checked there.

@sissiwup
Copy link

sissiwup commented Aug 19, 2022

in blink.py:

        self._parse_downloaded_items(
            result, camera, path, delay, debug, formatted_date)

def _parse_downloaded_items(self, result, camera, path, delay, debug, formatted_date):
    """Parse downloaded videos."""

.....

        if created_at < formatted_date:
            _LOGGER.debug("%s: %s is marked to old.",
                          camera_name, address)
            continue

@sissiwup sissiwup mentioned this issue Aug 19, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blink-api-issue There is an issue with the Blink API that needs to be addressed before the issue can be solved bug There is an issue causing unexpected results help-wanted Assistance required due to lack of resources for testing or complexity
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants