XMLTV guide data

Want to write your own code to work with a HDHomeRun or work with the HDHomeRun DVR? We are happy to help with concepts, APIs, best practices.
djp952
Posts: 1213
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD USA

Re: XMLTV guide data

Post by djp952 »

nickk wrote:
Thu Dec 12, 2019 7:34 pm
It is handled as a set so I think the category output is in alphabetical order.

I might be able to add an attribute - let me check...

Nick
They appear to be in genre priority, from least to most specific (generally). garyan2 linked me to and old TMS document (also found at another site), the previous top level category element was pretty much and exact match to those old genres from 2006.

I'm good with the order and the data, it's like the channel display-name elements, as long as the order is predictable it works as-is. No need to change anything that was just a general annoyance about the loose schema :).

The TMS document did reference they used a priority flag for their genres, if an attribute was present to indicate that I could also just find the second highest. But again, no need to change anything!!

garyan2
Posts: 44
Joined: Sun Aug 19, 2018 9:36 am
Contact:

Re: XMLTV guide data

Post by garyan2 »

Depending on the order of elements is risky, so I evaluate them all as a group. Having them is great for identifying what type of program it is. Knowing what the values could be allows us to filter them out from being reported as genres or such.

showType: Feature Film, Short Film, TV Movie, Miniseries, Series, Special, Sports event, Sports non-event, Paid Programming, Theatre Event

Basically, for my program, any category value that is not any of the above showTypes is a genre.

garyan2
Posts: 44
Joined: Sun Aug 19, 2018 9:36 am
Contact:

Re: XMLTV guide data

Post by garyan2 »

I am getting (403) Forbidden responses when trying to pull the XMLTV file using my program, but a manual request in a browser works. I noticed this late last night. Do we need header information for the requests, now?

djp952
Posts: 1213
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD USA

Re: XMLTV guide data

Post by djp952 »

garyan2 wrote:
Tue Dec 24, 2019 7:17 am
I am getting (403) Forbidden responses when trying to pull the XMLTV file using my program, but a manual request in a browser works. I noticed this late last night. Do we need header information for the requests, now?
Your Accept-Encoding request header needs to have "gzip" in the list. Depending on what you're using for HTTP it may decompress for you otherwise you'll have to decompress the response body.

libcurl with zlib built in was painless, anyway. I send in "identity, gzip, deflate" from my program.

LMK if I can help in any way!

garyan2
Posts: 44
Joined: Sun Aug 19, 2018 9:36 am
Contact:

Re: XMLTV guide data

Post by garyan2 »

djp952 wrote:
Tue Dec 24, 2019 7:45 am
garyan2 wrote:
Tue Dec 24, 2019 7:17 am
I am getting (403) Forbidden responses when trying to pull the XMLTV file using my program, but a manual request in a browser works. I noticed this late last night. Do we need header information for the requests, now?
Your Accept-Encoding request header needs to have "gzip" in the list. Depending on what you're using for HTTP it may decompress for you otherwise you'll have to decompress the response body.

libcurl with zlib built in was painless, anyway. I send in "identity, gzip, deflate" from my program.

LMK if I can help in any way!
I already had that. Looks like I need a user agent identified. Since it worked before without one, I'm now wondering if this is the next stage in restricting access to the JSON guide data and the apps/user agents need to be approved.

nickk
Silicondust
Posts: 15908
Joined: Tue Jan 13, 2004 9:39 am

Re: XMLTV guide data

Post by nickk »

A valid user-agent is required - it should identify the app and the version of the app.

Nick

nickk
Silicondust
Posts: 15908
Joined: Tue Jan 13, 2004 9:39 am

Re: XMLTV guide data

Post by nickk »

BTW - when you get an error such as a 403 the server also returns a message indicating what was wrong.

Nick

garyan2
Posts: 44
Joined: Sun Aug 19, 2018 9:36 am
Contact:

Re: XMLTV guide data

Post by garyan2 »

I'm not seeing any message that would tell me what is wrong.

On a somewhat related note, I have a user with a HDHR3-CC that continuously gets a 403 Forbidden error. I haven't found anything in the response to indicate what is wrong. I am providing the UserAgent and with the same code I can download XMLTV for my HDHR4-US tuners.

EDIT: make that at least 2 users for HDHR3-CC.

bigfan99
Posts: 50
Joined: Wed Oct 30, 2019 11:41 am

Re: XMLTV guide data

Post by bigfan99 »

I am one of Gary's affected users. Here is the sequence that Gary referenced:

Code: Select all

C:\temp>hdhr2mxf
Found HDHomeRun PRIME HDHR3-CC (xxxxxxxx) with firmware 20190621.
Found HDHomeRun SERVIO HHDD-2TB (xxxxxxxx) with firmware 20190621.
HDHomeRun DVR Service is active.
Using available 14-day XMLTV file from SiliconDust.
http://my.hdhomerun.com/api/xmltv.php?DeviceAuth=xxxxxxxx
The remote server returned an error: (403) Forbidden.


Generated .mxf file contains 1 lineups, 0 services, 0 series, 0 programs, and 0 people with 0 image links.
Execution time was 00:00:01.9231100
--Rob
Last edited by bigfan99 on Mon Dec 30, 2019 1:57 pm, edited 1 time in total.

djp952
Posts: 1213
Joined: Wed Oct 01, 2008 8:46 pm
Device ID: 131EB7F7;131ED0E0
Location: Elkridge, MD USA

Re: XMLTV guide data

Post by djp952 »

You should probably URL encode the DeviceAuth string to convert "/" to "%2F", but in practice that doesn't seem to matter much :)

Not to speak for NickK, but I was online and a bit bored right now ... lol

In this case, and I hope you don't mind (NOTE: you should probably remove the DeviceAuth string from your post above), it appears that the device isn't associated with a DVR account. Gary, you can hit the "account" API to get back an account status JSON, which will indicate if the device is authorized or not. For example, using the DeviceAuth for the user (again, I hope you don't mind I did this):

Account API: http://api.hdhomerun.com/api/account?DeviceAuth=XXXXXX

Code: Select all

{
    "AccountEmail": null,
    "AccountDeviceIDs": [
        "XXXXXXXX",
        "XXXXXXXX"
    ]
}
Here is what I get back for my account, note the "DvrActive" element.

Code: Select all

{
    "AccountEmail": "xxxxxx@xxxxx.xxx",
    "AccountDeviceIDs": [
        "XXXXXXXX",
        "XXXXXXXX"
    ],
    "DvrActive": 1,
    "AccountState": "Active"
}
signcarver gave me a good tip that I follow as well, I hit the account API for each discovered device individually so I can differentiate which ones are authorized or not so I can limit the combined DeviceAuth string to just the DVR authorized devices.

nickk
Silicondust
Posts: 15908
Joined: Tue Jan 13, 2004 9:39 am

Re: XMLTV guide data

Post by nickk »

Quick one first - the URL should be api.hdhomerun.com not my.hdhomerun.com.

I am looking into the 403.

Edit - fixed the problem of the error message not displaying. It is reporting not-subscribed.

Nick

garyan2
Posts: 44
Joined: Sun Aug 19, 2018 9:36 am
Contact:

Re: XMLTV guide data

Post by garyan2 »

djp952 wrote:
Fri Dec 27, 2019 8:45 am
You should probably URL encode the DeviceAuth string to convert "/" to "%2F", but in practice that doesn't seem to matter much :)

Not to speak for NickK, but I was online and a bit bored right now ... lol

In this case, and I hope you don't mind (NOTE: you should probably remove the DeviceAuth string from your post above), it appears that the device isn't associated with a DVR account. Gary, you can hit the "account" API to get back an account status JSON, which will indicate if the device is authorized or not. For example, using the DeviceAuth for the user (again, I hope you don't mind I did this):

Account API: http://api.hdhomerun.com/api/account?DeviceAuth=XXXXXX

Code: Select all

{
    "AccountEmail": null,
    "AccountDeviceIDs": [
        "XXXXXXXX",
        "XXXXXXXX"
    ]
}
Here is what I get back for my account, note the "DvrActive" element.

Code: Select all

{
    "AccountEmail": "xxxxxx@xxxxx.xxx",
    "AccountDeviceIDs": [
        "XXXXXXXX",
        "XXXXXXXX"
    ],
    "DvrActive": 1,
    "AccountState": "Active"
}
signcarver gave me a good tip that I follow as well, I hit the account API for each discovered device individually so I can differentiate which ones are authorized or not so I can limit the combined DeviceAuth string to just the DVR authorized devices.
I don't mind at all... any help is appreciated. I did try url encoding the deviceauth string thinking the same thing, but it didn't change the results.

Interesting result on the DvrActive response. I go through all the devices from discovery and simply OR the DvrActive responses together to determine if the service is active. His -CC device does return a false, though. Does the SERVIO return a DvrActive = true response always and that is throwing me off?

garyan2
Posts: 44
Joined: Sun Aug 19, 2018 9:36 am
Contact:

Re: XMLTV guide data

Post by garyan2 »

nickk wrote:
Fri Dec 27, 2019 8:53 am
Quick one first - the URL should be api.hdhomerun.com not my.hdhomerun.com.

I am looking into the 403.

Edit - fixed the problem of the error message not displaying. It is reporting not-subscribed.

Nick
Okay, seeing the response now. Also, changed all URLs to be api.hdhomerun.com rather than my.hdhomerun.com.

signcarver
Expert
Posts: 8934
Joined: Wed Jan 24, 2007 1:04 am
Device ID: 131B34B7 13231F92 1070A18E 1073ED6F 15300C36

Re: XMLTV guide data

Post by signcarver »

There are 3 ways one may have dvr service subscription, first is through kickstarter/beta purchase ($30 or higher ks, $60 beta prior to general release) whose year hasn't started yet. 2nd is when a year of service was purchase after release ($35, any $30 purchase of such would have expired) and 3rd is through purchase of scribe/servio where the device gets one year (supposedly added for each such device but isn't automatically applied yet as far as I know).

If their subscription is based on the servio, i'm not sure they will/are supposed to be authorized for xml data as their subscription status i believe won't exist (not subscribed) as they haven't "subscribed" (forget exactly what it was but it may have been mentioned in the unofficial kodi thread) but with many of the api's making sure to include the servio's DeviceAuth along with the tuners' would be required.

This may be problematic for the way some may wish to get data by device vs data by all devices but at the very least, i would make sure to concatenate any servio/scribe auth with that of the tuner as the tuner has the guide data but the servio/scribe will have the potential subscription

nickk
Silicondust
Posts: 15908
Joined: Tue Jan 13, 2004 9:39 am

Re: XMLTV guide data

Post by nickk »

All three ways should result in xml data access.

BTW - I updated my.hdhomerun.com/api/ to redirect rather than proxy so it is more obvious that api.hdhomerun.com should be used.

Nick

Post Reply