Code Monkey home page Code Monkey logo

hdhr_vcr-as's Introduction

hdhr_VCR

A pretty darn good VCR "plus" script that works on all HDHomeRun devices, and is free to use! An OSX faceless/background script that makes recording TV shows and Movies on HDHomeRun very easy.

Show List

Why?

I wanted a quick way to record a TV show, without setting up a large system, like Plex or HDHomeRuns' own DVR software. I call it a VCR app, as while it does use guide data to pull name / season / episode number / episode name / show length, it does not present like a normal DVR. It is more of a Smart VCR

Requirements

  1. OSX
  2. Due to poor planning, this will only work in the en_US region, sorry
  3. JSONHelper is required, available for free.
  4. A configured HDHomeRun device from https://www.silicondust.com
  5. hdhr_VCR will also need access to the following paths:
  • ~/Documents/hdhr_VCR.json
  • ~/Library/Caches/hdhr_VCR/
  • ~/Library/Logs/hdhr_VCR.log

Features

  • Auto discovery of all HDHomeRun devices on your network!
  • Uses built-in guide data, and lineup data, to automatically name the shows you are recording.
    • The free guide data is only for the next 4-6 hours. We will attempt to pull fresh data right before a show starts, so in most cases, the information does get pulled correctly. I believe if you pay for HDHomeRuns own DVR software, the guide data is much longer, and the script would handle that.
  • Runs in the background, but allows easy editing of existing saved shows.
  • Uses caffeinate to ensure that the system does not go to sleep during a recording.
  • Add a show or series in 10 seconds.
  • Robust logging, allows you to see exactly what is happening on the script at any time.

How to use

  1. Download the file hdhr_VCR.applescript, and open this in Script Editor.
  2. Choose "Export..." in the File Menu.
  3. Save as "Application" and check "Stay open after run handler" MUST be checked for this to work.
  4. Save the file with the name hdhr_VCR, and then save this in the Application Folder.
  5. Now we have a compiled application, we want to open it.

When you first run this, OSX will prompt multiple times for various system permissions. Please grant all of these.

  1. You will then be presented with options to see the existing shows, add a show, or "Run"
  • More about "Run" later.

Let's start with "Add", as this is the main function.

Title Screen

  1. If you have multiple tuners, you will be asked which one you would like to use for this recording.
  2. You will be presented with a channel list. Select the channel this show is on.

Channel List

  1. Once you select your channel, you will see a screen that details the shows that are on in the next ~ 4 hours. HDHR Guide

  2. You will notice that there is a "Manual Add" option. This will allow you to select a time past the 4 hours of guide data provided. If you wish to follow this route, you can skip to https://github.com/identd113/hdhr_VCR-AS#manual-add

Select a show, and click "Next"

Show Info

  • A "Single" is a one-off recording. Once the recording is complete, the show will be marked as inactive.
  • If you selected a "Series" you can select as many days of the week you would like to record. This will repeat every week.

You will then select where you want the file to be saved. The default location is "/Volumes/", but you will need to select a specific location. Any attempts to select "/Volumes/" as the destination will re prompt you for a valid location.

If you own a "Extend" device, or a device that has transcode capabilities, you can select which profile you wish to use.

Manual Add

If you wish to schedule a recording outside of the 4 hour guide window, you can select Manual Add, and add this show/series.

You will then be asked to specify a time, it is done a bit strangely. We use 24 hour decimal time

  • For example, if you wanted to record a show at 6:45 PM, you would enter 18.75. (.5 of an hour, is 30 minutes. .75 of an hour is 45 minutes.)
  • If you attempt to use a time that has already passed for today, it will assume you mean tomorrow.
  • When picking a time, you can select anytime during the show time span, and we will adjust the start time to align with the real start. For example, if a certain show starts at 10:35 PM, and the show runs 62 minutes, you could enter any time between 22.56 to 23.58, and we would set the start time to 22.56 (10:35)

You will now have the ability to set the recordings name. The name provided is just temporary, as we will try to pull the guide data right before the recording starts.

  1. In this same window, you will also tell the script if this is a a "Single" or a "Series"
  • A "Series" is meant for shows that air at the same time, perhaps 1 day or week, or 7, at a certain time.
  1. The next screen allows you to tell us which day you wish to record. It will default to today.
  • If you selected a "Series" you can select as many days as you wish.
  • If you select "Single" you can only select one day.

This allows you to set up a recording up to a week in advance.

END Manual Add

What is Run?

"You told me you would tell me what "Run" is for?

The button that shows "Run" in almost all dialogs, will drop you back into the idle() handler. This can be used to go back, or start over, for example if entering the incorrect information when adding a show. This allows the script to run as needed. It is important to know that the idle() is NOT running when a dialog is open. If a dialog stays open forever, we will never be able to record, or update anything in the script. Because of this, dialogs have a timeout of 60 seconds, before auto closing. The choose from list dialog can NOT be dismissed automatically. Our use case is the show info list.

"I did that, but nothing happens!"

That is accurate. When the script is configured with a show, it is faceless, and you do not need to do anything, other than allow it to run.

"I want to add or edit a show"

If you click the icon in the Dock, you will be presented with the main window, so you can do such things.

"How do I know something is happening?

We use notifications to alert the user to recordings being started, in progress, and completing. This may cause lots of notifications to occur, if a lot of shows are scheduled. If there is a better way to be able to tell the user something, let me know.

"I need to quit the script, but I have a recording in progress"

If you want to quit the script, the best way to do so is being in a "run" state (faceless) and then issuing a command q, or selecting "Quit" from the hdhr_VCR File menu.

  • If a show is currently recording, you will be prompted regarding if you want to cancel the recordings, before quitting. You can choose to go back to the main screen, quit, and cancel all recordings, or quit, but do not cancel the shows. Since the recording is done with "curl", hdhr_VCR does not need to be open once a recording has already started.

**In almost every case, you should choose "No". **

Nitty gritty

Uses records to store complex data sets.

This is an example of a what data of a show recording contains:

{show_title:Curious George S01E21 Surprise Quints; Muddy Monkey, show_time:16, show_length:30, show_air_date:Monday, Tuesday, Wednesday, Thursday, Friday, show_transcode:None, show_temp_dir:alias Raid3:DVR Tests:, show_dir:alias Raid3:DVR Tests:, show_channel:2.4, show_active:true, show_id:0489dfb9fd492970694c13d25e2f457a, show_recording:false, show_last:date Tuesday, June 15, 2021 at 4:30:00 PM, show_next:date Wednesday, June 16, 2021 at 4:00:00 PM, show_end:date Wednesday, June 16, 2021 at 4:30:00 PM, notify_upnext_time:missing value, notify_recording_time:missing value, show_is_series:true, hdhr_record:105404BE}

Example of a tuner record:

{hdhr_lineup_update:missing value, hdhr_guide_update:missing value, discover_url:http://10.0.1.101/discover.json, lineup_url:http://10.0.1.101/lineup.json, device_id:DEADBEEF, does_transcode:1, hdhr_lineup:missing value, hdhr_guide:missing value, hdhr_model:missing value, channel_mapping:missing value, BaseURL:http://10.0.1.101, statusURL:http://10.0.1.101/status.json}

The hdhr_guide and hdhr_lineup contain the entire json result of the lineup, and guide data. We use this as a cache, so we only make a "new" API call every 2 hours, or when a show starts recording.

Special considerations

  • The "heavy lifting" is done with curl, which downloads the data to a local drive. The script manages the show and device logic.

  • If there are multiple HDHR device on the network, you will be asked which one you want to use when adding a show.

  • When adding a show, we will attempt to write a test file to that location (and remove it) right away, so we can get through any of the OS X disk access prompts. This file is written/removed every 5 minutes during a recording. This will update the file size, as seen in Finder.

  • We use notifications to alert the user to imminent events

    • 1 hour before the show, and then every 15 minutes
    • Starting a recording
    • Every 15 minutes during a recording
    • End of a recording
  • If the system is restarting or shutting down, we will see that, and not prompt the user cancel the recordings, they will just be canceled.

hdhr_VCR now has a logger, which by default is named hdhr_VCR.log, that gives us more information of what is happening, without flooding the notifications.

I hope this can be collaborative project, so other options that you use can be added.

-MikeW

hdhr_vcr-as's People

Contributors

identd113 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hdhr_vcr-as's Issues

Modernize method of saving show_info and app settings

We can use json helper to convert records to json, and vice versa. This would allow us to store all of our data in a flat json file, instead of just a flat unorganized text file. This has mahy subtasks, which I can detail later.

Manually added shows don’t update

Manually added shows do not get updated after adding them they do get updated a second or two before the beginning of the show which then we could potentially miss the show start

overlapping shows

Shows can slightly overlap, cause a failed recording on the next show. Since we send the recording off to curl as a background process, we don't have much control here. I do not know a clean way to prevent this from ov but wanted to log this for future consideration.

Trying to use

Very pleased to find your project, which I am hoping to use with my HDHomeRun device. I agree with your comments that Plex etc are far too complicated - I just want to start some recordings, forget, and then watch later.

Quick comments:
Readme, How to use, point 3 - should be “Export as” rather than “Save as”.
A syntax error on date "Thursday, January 1, 1970 at 12:00:00 AM” (I am in Australia - locale en_AU) - changed to "Thursday, 1 January 1970 at 12:00:00 am”. Is the locale = en_US test needed?

When I run hdr_VCR, this error results:

"Can’t get LineupURL of {DiscoverURL:"http://10.1.1.184:49206/discover.json\", BaseURL:"http://10.1.1.184:49206\", LocalIP:"10.1.1.184:49206", StorageID:"A27C5E1F-7D96-300A-DC7E-B42C7CE87539", StorageURL:"http://10.1.1.184:49206/recorded_files.json\"}." number -1728 from LineupURL of {DiscoverURL:"http://10.1.1.184:49206/discover.json", BaseURL:"http://10.1.1.184:49206", LocalIP:"10.1.1.184:49206", StorageID:"A27C5E1F-7D96-300A-DC7E-B42C7CE87539", StorageURL:"http://10.1.1.184:49206/recorded_files.json"}

Also, the log shows a warning “Unable to determine transcode settings”.

If I run “https://ipv4-api.hdhomerun.com/discover” in the browser, the result is:
{
"DeviceID": "12526E41",
"LocalIP": "10.1.1.201",
"BaseURL": "http://10.1.1.201",
"DiscoverURL": "http://10.1.1.201/discover.json",
"LineupURL": "http://10.1.1.201/lineup.json"
},
{
"StorageID": "A27C5E1F-7D96-300A-DC7E-B42C7CE87539",
"LocalIP": "10.1.1.184:49206",
"BaseURL": "http://10.1.1.184:49206",
"DiscoverURL": "http://10.1.1.184:49206/discover.json",
"StorageURL": "http://10.1.1.184:49206/recorded_files.json"
}

The second part of this result (with the 10.1.1.184 address, as per the error message), does not have a LineupURL. Running “http://10.1.1.184:49206/lineup.json” results in a 404 not found error.

Hoping you can help.

On quit

List which shows are marked as recording

Refactor show_id

show_id should have a value that can be decoded to recreate the show specifics. Should a show change, we should not change the show_id, as it is immutable.

Time_slide

Make sure time slide works for shows added automatically. time slide is the default selection of the days of the week when adding a series

Error on First Run

Downloaded the AppleScript - > Export to Application

On first run I get

PDM - CleanShot- 23@2x

Finally fix future recording

Create record with items that represent seconds one per second, maybe minutes. Each item is a Boolean, and we need to be able to set large ranges. This will allow us to build a look up table. We need to be aware of how many tuners we can use.

Validate hdhr_config

When we try to save config data, we zero out both show_info and config section. If something in hdhr_config is invalid, skip it and just save show_info

Fix logging

We are adding an extra linefeed to the end of the log file, so it shows as 0A0A as the last chars in a hex editor. We need to clean this up.

Revert (version of me) change

Recent changes to pull the application version rather then the version stored in a var. this won't work, as the script is shipped as code and not a premade binary

Add analytics

Track counts of recorded shows
Track GB recorded
Etc

Remap buttons

run() should call setup() and reopen should call main()

Series/Single

When using the "Single" record option, we should present the list of days, to allow future recording, but disallow the user to select multiple days.

Wrong time when adding channel

When we add a show, the starting time always shows 5 o'clock. This appears to be just UI thing, as the actual time is set correctly

Version Control

Write a version control system
Display "Update Available" in title using hdhr_VCR_version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.