Video Downloader - Create/Save to folder named mmmm.yyyy

Below is the config I’m using to download/save video’s from my Ring doorbell.
It’s working fine, however, I’d like it to save the files into their own folders based on the month/year.

Is there a way to create the folder if it doesn’t exist, then save the video into that folder for each month?
e.g.

December_2021
January_2022

service: downloader.download_file
data:
  url: '{{ state_attr(''camera.front_door'', ''video_url'') }}'
  subdir: '{{state_attr(''camera.front_door'', ''friendly_name'')}}'
  filename: >-
    {{ state_attr('camera.front_door', 'friendly_name') }} - {{
    now().strftime("%d-%m-%Y- %H.%M.%S") }} - TEST.mp4

Try this:

service: downloader.download_file
data:
  url: '{{ state_attr("camera.front_door", "video_url") }}'
  subdir: '{{state_attr("camera.front_door", "friendly_name")}}/{{ now().strftime("%m.%Y") }}'
  filename: >-
    {{ state_attr('camera.front_door', 'friendly_name') }} - {{
    now().strftime("%d-%m-%Y- %H.%M.%S") }} - TEST.mp4

I would also like to recommend that you use the ISO8601 format for the dates. That way, the file list will be in the correct chronological order when sorted alphabetically.

service: downloader.download_file
data:
  url: '{{ state_attr("camera.front_door", "video_url") }}'
  subdir: '{{state_attr("camera.front_door", "friendly_name")}}/{{ now().strftime("%Y-%m") }}'
  filename: >-
    {{ state_attr('camera.front_door', 'friendly_name') }} - {{
    now().strftime("%Y%m%dT%H%M%S") }} - TEST.mp4

Colons in filenames are ugly, so I used the form without delimiters for filename.

1 Like

Thanks, This works perfectly!

For the formatting, I’m from the UK, so rather weird with how I’m familiar with viewing the dates (DD/MM/YYYY)

Another question on this (I’m sure I’ve seen a post about it before)
But is there a way to view ‘Todays’ downloaded files via a drop down list and play them back within A card?

Sorry, I don’t know. You might be better off starting a new topic for that.

If it was here on the forum, try searching with some keywords and in:seen.

1 Like

Just wanting to bump this as I’d like to add another sub folder for the day, I did gave it a go buy my code is really bad and doesn’t work.

Can anybody help add another folder to this code?

service: downloader.download_file
data:
  url: '{{ state_attr("camera.front_door", "video_url") }}'
  subdir: '{{state_attr("camera.front_door", "friendly_name")}}/{{ now().strftime("%m.%Y") }}'
  filename: >-
    {{ state_attr('camera.front_door', 'friendly_name') }} - {{
    now().strftime("%d-%m-%Y- %H.%M.%S") }} - TEST.mp4

See if this works:

service: downloader.download_file
data:
  url: '{{ state_attr("camera.front_door", "video_url") }}'
  subdir: '{{state_attr("camera.front_door", "friendly_name")}}/{{ now().strftime("%m.%Y") }}/{{ now().strftime("%d") }}'
  filename: >-
    {{ state_attr('camera.front_door', 'friendly_name') }} - {{
    now().strftime("%d-%m-%Y- %H.%M.%S") }} - TEST.mp4
2 Likes

So easy when you see it!
Thanks again!!!