Jump to content

LiveTV\Timers POST to create a scheduled recording


jrhessey

Recommended Posts

jrhessey

I've got a small R script to test that grabs some sporting events and their info.  I'm looking at the POST portion of the livetv/timers API and I'm a little confused here.  OK, a lot confused.  ha!

 

What fields in that code are required?  Can I submit a couple fields and Emby fill in the rest?  Sorry if these are dumb questions, new to API stuff and I'm trying toi figure some stuff out.

{
  "Status": "New",
  "SeriesTimerId": "string",
  "ExternalSeriesTimerId": "string",
  "RunTimeTicks": 0,
  "ProgramInfo": {
    "Name": "string",
    "OriginalTitle": "string",
    "ServerId": "string",
    "Id": "string",
    "Etag": "string",
    "PlaylistItemId": "string",
    "DateCreated": "2019-02-25T14:47:08.014Z",
    "ExtraType": "string",
    "AirsBeforeSeasonNumber": 0,
    "AirsAfterSeasonNumber": 0,
    "AirsBeforeEpisodeNumber": 0,
    "DisplaySpecialsWithSeasons": true,
    "CanDelete": true,
    "CanDownload": true,
    "HasSubtitles": true,
    "SupportsResume": true,
    "PreferredMetadataLanguage": "string",
    "PreferredMetadataCountryCode": "string",
    "SupportsSync": true,
    "Container": "string",
    "SortName": "string",
    "ForcedSortName": "string",
    "Video3DFormat": "HalfSideBySide",
    "PremiereDate": "2019-02-25T14:47:08.014Z",
    "ExternalUrls": [
      {
        "Name": "string",
        "Url": "string"
      }
    ],
    "MediaSources": [
      {
        "Protocol": "File",
        "Id": "string",
        "Path": "string",
        "EncoderPath": "string",
        "EncoderProtocol": "File",
        "Type": "Default",
        "Container": "string",
        "Size": 0,
        "Name": "string",
        "IsRemote": true,
        "RunTimeTicks": 0,
        "ReadAtNativeFramerate": true,
        "DiscardCorruptPts": true,
        "FillWallClockDts": true,
        "IgnoreDts": true,
        "IgnoreIndex": true,
        "SupportsTranscoding": true,
        "SupportsDirectStream": true,
        "SupportsDirectPlay": true,
        "IsInfiniteStream": true,
        "RequiresOpening": true,
        "OpenToken": "string",
        "RequiresClosing": true,
        "LiveStreamId": "string",
        "BufferMs": 0,
        "RequiresLooping": true,
        "SupportsProbing": true,
        "Video3DFormat": "HalfSideBySide",
        "MediaStreams": [
          {
            "Codec": "string",
            "CodecTag": "string",
            "Language": "string",
            "ColorTransfer": "string",
            "ColorPrimaries": "string",
            "ColorSpace": "string",
            "Comment": "string",
            "TimeBase": "string",
            "CodecTimeBase": "string",
            "Title": "string",
            "Extradata": "string",
            "VideoRange": "string",
            "DisplayTitle": "string",
            "NalLengthSize": "string",
            "IsInterlaced": true,
            "IsAVC": true,
            "ChannelLayout": "string",
            "BitRate": 0,
            "BitDepth": 0,
            "RefFrames": 0,
            "PacketLength": 0,
            "Channels": 0,
            "SampleRate": 0,
            "IsDefault": true,
            "IsForced": true,
            "Height": 0,
            "Width": 0,
            "AverageFrameRate": 0,
            "RealFrameRate": 0,
            "Profile": "string",
            "Type": "Audio",
            "AspectRatio": "string",
            "Index": 0,
            "Score": 0,
            "IsExternal": true,
            "DeliveryMethod": "Encode",
            "DeliveryUrl": "string",
            "IsExternalUrl": true,
            "IsTextSubtitleStream": true,
            "SupportsExternalStream": true,
            "Path": "string",
            "PixelFormat": "string",
            "Level": 0,
            "IsAnamorphic": true
          }
        ],
        "Formats": [
          "string"
        ],
        "Bitrate": 0,
        "Timestamp": "None",
        "RequiredHttpHeaders": {
          "additionalProp1": "string",
          "additionalProp2": "string",
          "additionalProp3": "string"
        },
        "TranscodingUrl": "string",
        "TranscodingSubProtocol": "string",
        "TranscodingContainer": "string",
        "AnalyzeDurationMs": 0,
        "DefaultAudioStreamIndex": 0,
        "DefaultSubtitleStreamIndex": 0
      }
    ],
    "CriticRating": 0,
    "GameSystemId": 0,
    "GameSystem": "string",
    "ProductionLocations": [
      "string"
    ],
    "Path": "string",
    "OfficialRating": "string",
    "CustomRating": "string",
    "ChannelId": "string",
    "ChannelName": "string",
    "Overview": "string",
    "Taglines": [
      "string"
    ],
    "Genres": [
      "string"
    ],
    "CommunityRating": 0,
    "RunTimeTicks": 0,
    "PlayAccess": "Full",
    "AspectRatio": "string",
    "ProductionYear": 0,
    "Number": "string",
    "ChannelNumber": "string",
    "IndexNumber": 0,
    "IndexNumberEnd": 0,
    "ParentIndexNumber": 0,
    "RemoteTrailers": [
      {
        "Url": "string",
        "Name": "string"
      }
    ],
    "ProviderIds": {
      "additionalProp1": "string",
      "additionalProp2": "string",
      "additionalProp3": "string"
    },
    "IsFolder": true,
    "ParentId": "string",
    "Type": "string",
    "People": [
      {
        "Name": "string",
        "Id": "string",
        "Role": "string",
        "Type": "Actor",
        "PrimaryImageTag": "string"
      }
    ],
    "Studios": [
      {
        "Name": "string",
        "Id": 0
      }
    ],
    "GenreItems": [
      {
        "Name": "string",
        "Id": 0
      }
    ],
    "ParentLogoItemId": "string",
    "ParentBackdropItemId": "string",
    "ParentBackdropImageTags": [
      "string"
    ],
    "LocalTrailerCount": 0,
    "UserData": {
      "Rating": 0,
      "PlayedPercentage": 0,
      "UnplayedItemCount": 0,
      "PlaybackPositionTicks": 0,
      "PlayCount": 0,
      "IsFavorite": true,
      "Likes": true,
      "LastPlayedDate": "2019-02-25T14:47:08.015Z",
      "Played": true,
      "Key": "string",
      "ItemId": "string"
    },
    "RecursiveItemCount": 0,
    "ChildCount": 0,
    "SeriesName": "string",
    "SeriesId": "string",
    "SeasonId": "string",
    "SpecialFeatureCount": 0,
    "DisplayPreferencesId": "string",
    "Status": "string",
    "AirTime": "string",
    "AirDays": [
      "Sunday"
    ],
    "Tags": [
      "string"
    ],
    "PrimaryImageAspectRatio": 0,
    "Artists": [
      "string"
    ],
    "ArtistItems": [
      {
        "Name": "string",
        "Id": "string"
      }
    ],
    "Album": "string",
    "CollectionType": "string",
    "DisplayOrder": "string",
    "AlbumId": "string",
    "AlbumPrimaryImageTag": "string",
    "SeriesPrimaryImageTag": "string",
    "AlbumArtist": "string",
    "AlbumArtists": [
      {
        "Name": "string",
        "Id": "string"
      }
    ],
    "SeasonName": "string",
    "MediaStreams": [
      {
        "Codec": "string",
        "CodecTag": "string",
        "Language": "string",
        "ColorTransfer": "string",
        "ColorPrimaries": "string",
        "ColorSpace": "string",
        "Comment": "string",
        "TimeBase": "string",
        "CodecTimeBase": "string",
        "Title": "string",
        "Extradata": "string",
        "VideoRange": "string",
        "DisplayTitle": "string",
        "NalLengthSize": "string",
        "IsInterlaced": true,
        "IsAVC": true,
        "ChannelLayout": "string",
        "BitRate": 0,
        "BitDepth": 0,
        "RefFrames": 0,
        "PacketLength": 0,
        "Channels": 0,
        "SampleRate": 0,
        "IsDefault": true,
        "IsForced": true,
        "Height": 0,
        "Width": 0,
        "AverageFrameRate": 0,
        "RealFrameRate": 0,
        "Profile": "string",
        "Type": "Audio",
        "AspectRatio": "string",
        "Index": 0,
        "Score": 0,
        "IsExternal": true,
        "DeliveryMethod": "Encode",
        "DeliveryUrl": "string",
        "IsExternalUrl": true,
        "IsTextSubtitleStream": true,
        "SupportsExternalStream": true,
        "Path": "string",
        "PixelFormat": "string",
        "Level": 0,
        "IsAnamorphic": true
      }
    ],
    "PartCount": 0,
    "ImageTags": {
      "additionalProp1": "string",
      "additionalProp2": "string",
      "additionalProp3": "string"
    },
    "BackdropImageTags": [
      "string"
    ],
    "ParentLogoImageTag": "string",
    "ParentArtItemId": "string",
    "ParentArtImageTag": "string",
    "SeriesThumbImageTag": "string",
    "SeriesStudio": "string",
    "ParentThumbItemId": "string",
    "ParentThumbImageTag": "string",
    "ParentPrimaryImageItemId": "string",
    "ParentPrimaryImageTag": "string",
    "Chapters": [
      {
        "StartPositionTicks": 0,
        "Name": "string",
        "ImageTag": "string"
      }
    ],
    "LocationType": "FileSystem",
    "MediaType": "string",
    "EndDate": "2019-02-25T14:47:08.015Z",
    "LockedFields": [
      "Cast"
    ],
    "LockData": true,
    "Width": 0,
    "Height": 0,
    "CameraMake": "string",
    "CameraModel": "string",
    "Software": "string",
    "ExposureTime": 0,
    "FocalLength": 0,
    "ImageOrientation": "TopLeft",
    "Aperture": 0,
    "ShutterSpeed": 0,
    "Latitude": 0,
    "Longitude": 0,
    "Altitude": 0,
    "IsoSpeedRating": 0,
    "SeriesTimerId": "string",
    "ChannelPrimaryImageTag": "string",
    "StartDate": "2019-02-25T14:47:08.015Z",
    "CompletionPercentage": 0,
    "IsRepeat": true,
    "IsNew": true,
    "EpisodeTitle": "string",
    "IsMovie": true,
    "IsSports": true,
    "IsSeries": true,
    "IsLive": true,
    "IsNews": true,
    "IsKids": true,
    "IsPremiere": true,
    "TimerId": "string",
    "MovieCount": 0,
    "SeriesCount": 0,
    "AlbumCount": 0,
    "SongCount": 0,
    "MusicVideoCount": 0
  },
  "Id": "string",
  "Type": "string",
  "ServerId": "string",
  "ExternalId": "string",
  "ChannelId": "string",
  "ExternalChannelId": "string",
  "ChannelName": "string",
  "ChannelPrimaryImageTag": "string",
  "ProgramId": "string",
  "ExternalProgramId": "string",
  "Name": "string",
  "Overview": "string",
  "StartDate": "2019-02-25T14:47:08.015Z",
  "EndDate": "2019-02-25T14:47:08.015Z",
  "ServiceName": "string",
  "Priority": 0,
  "PrePaddingSeconds": 0,
  "PostPaddingSeconds": 0,
  "IsPrePaddingRequired": true,
  "ParentBackdropItemId": "string",
  "ParentBackdropImageTags": [
    "string"
  ],
  "IsPostPaddingRequired": true,
  "KeepUntil": "UntilDeleted"
} 
Link to comment
Share on other sites

PenkethBoy

from updating emby items via the API - you need to get the full json "record" for that item - be it a Movie, Series, Episode etc etc

 

And once you modify some properties you need to return the full json "record" 

 

Emby does not work with partial items - look at swagger (API link bottom of Server Dashboard home page) - you can test out options and see what comes back

 

I just looked at a single movie and the returned json is 784 lines long :) - just to change a studio name in a test script

 

Luke has said a while ago this may change but for now it works if a bit on the verbose side

 

I'm using powershell but below should give you a clue

# ant-man and the wasp
$MediaUrl = $embyServerUrl + "/emby/users/" + $User.User.Id + "/items/158085"  + "?api_key=" + $User.AccessToken

# need to read full item to get all data - cannot return a partial update item
$TestResult = Invoke-WebRequest -Uri $MediaUrl -Method Get

$Media = $TestResult.Content | ConvertFrom-Json

# only for testing - save file
$Media | ConvertTo-Json -Verbose -Depth 100 | Out-File "$PSScriptRoot\Movie.json"

# to remove all studios
$media.studios = $Media.Studios -eq ""

# just to make sure it worked
$Media | ConvertTo-Json -Verbose -Depth 100 | Out-File "$PSScriptRoot\MovieModed.json"

$MediaUrl = $embyServerUrl + "/emby/Items/158085?api_key=" + $User.AccessToken

$result = Invoke-Webrequest -uri $MediaUrl -Method POST -Body ($Media | ConvertTo-Json) -ContentType "application/json"

158085 is a movie ID - Tip ID's are in the url's of the web app

 

Have Fun

Edited by PenkethBoy
Link to comment
Share on other sites

So the answer here is you need to retrieve the default timer and then change what needs to be changed and re-submit that.

Link to comment
Share on other sites

jrhessey

First off, thanks both of you for your replies.  I'm a little confused as it looks like your answers are a little different.  

 

So the answer here is you need to retrieve the default timer and then change what needs to be changed and re-submit that.

 

Here is the schema example from Swagger - Default Timer.  I just need to populate those fields and resubmit it the LiveTV\Timer POST?

{
  "RecordAnyTime": true,
  "SkipEpisodesInLibrary": true,
  "RecordAnyChannel": true,
  "KeepUpTo": 0,
  "RecordNewOnly": true,
  "Days": [
    "Sunday"
  ],
  "DayPattern": "Daily",
  "ImageTags": {
    "additionalProp1": "string",
    "additionalProp2": "string",
    "additionalProp3": "string"
  },
  "ParentThumbItemId": "string",
  "ParentThumbImageTag": "string",
  "ParentPrimaryImageItemId": "string",
  "ParentPrimaryImageTag": "string",
  "Id": "string",
  "Type": "string",
  "ServerId": "string",
  "ExternalId": "string",
  "ChannelId": "string",
  "ExternalChannelId": "string",
  "ChannelName": "string",
  "ChannelPrimaryImageTag": "string",
  "ProgramId": "string",
  "ExternalProgramId": "string",
  "Name": "string",
  "Overview": "string",
  "StartDate": "2019-02-25T20:32:06.636Z",
  "EndDate": "2019-02-25T20:32:06.636Z",
  "ServiceName": "string",
  "Priority": 0,
  "PrePaddingSeconds": 0,
  "PostPaddingSeconds": 0,
  "IsPrePaddingRequired": true,
  "ParentBackdropItemId": "string",
  "ParentBackdropImageTags": [
    "string"
  ],
  "IsPostPaddingRequired": true,
  "KeepUntil": "UntilDeleted"
} 
Link to comment
Share on other sites

PenkethBoy

no - Eric just said the same sort of thing as i did - basically pull a full record (timer in this case) amend and return the full record

 

i would ignore the schema (ive never even looked at them) - better to get a real live response - swagger is not always a 100% - things change

 

you can do this in swagger - pull back a live existing timer ( json) - save it and look at what fields are being used and what they contain - as "string" is very ambiguous

 

maybe setup several with different options and see how the data varies

 

TIP: As you setup a timer - if you have debug on for your logs - lots of interesting info is saved in the logs - remember the web app is essentially doing the same as you are trying to do via the api - so is useful to check what emby does in the background

 

 

amend something say RecordAnyChannel to false and send it back to emby (via your ap) to see if it updates ok etc

 

You are going to have to spend some time working out what matters and what does not - and also understand how emby works - its just a learning curve no rocket science involved :)

 

I'll try and help where i can - point you in the right direction if necessary etc

 

Good Luck

Link to comment
Share on other sites

jrhessey

no - Eric just said the same sort of thing as i did - basically pull a full record (timer in this case) amend and return the full record

 

i would ignore the schema (ive never even looked at them) - better to get a real live response - swagger is not always a 100% - things change

 

you can do this in swagger - pull back a live existing timer ( json) - save it and look at what fields are being used and what they contain - as "string" is very ambiguous

 

maybe setup several with different options and see how the data varies

 

TIP: As you setup a timer - if you have debug on for your logs - lots of interesting info is saved in the logs - remember the web app is essentially doing the same as you are trying to do via the api - so is useful to check what emby does in the background

 

 

amend something say RecordAnyChannel to false and send it back to emby (via your ap) to see if it updates ok etc

 

You are going to have to spend some time working out what matters and what does not - and also understand how emby works - its just a learning curve no rocket science involved :)

 

I'll try and help where i can - point you in the right direction if necessary etc

 

Good Luck

 

 

I see it now...  The default I posted and the actual timers look similar.  I think I'm getting dangerous now...  ha!  I'll plug in some values and see what I can get...

 

Thanks so much for your help!!

Link to comment
Share on other sites

jrhessey

I've got some of the data in separate sets.  How would you join them together??  The common field between the 2 is channelid and id and would join them on those 2 fields.  I just can't figure it out.

 

ShowInfo from Programs

Name                    : Womens College Basketball
ServerId                : 17ba4d76bfad44d68b835a4dc47a464b
Id                      : 368437
DateCreated             : 2019-02-26T05:52:38.0000000+00:00
SortName                : womens college basketball  columbia at harvard
ChannelId               : 319829
Overview                : From Ray Lavietes Pavilion in Boston.
Taglines                : {}
Genres                  : {Basketball}
RunTimeTicks            : 71999995904
ProviderIds             : @{SeriesZap2It=EP03061797}
ParentId                : 319829
Type                    : Program
Studios                 : {}
GenreItems              : {@{Name=Basketball; Id=46341}}
PrimaryImageAspectRatio : 0.666666666666667
ImageTags               : @{Primary=204b29a699648972e9406d7a06cce1ea}
BackdropImageTags       : {}
MediaType               : Video
EndDate                 : 2019-03-12T11:00:00.0000000+00:00
StartDate               : 2019-03-12T09:00:00.0000000+00:00
IsRepeat                : True
EpisodeTitle            : Columbia at Harvard
IsSports                : True
IsSeries                : True

Name                    : College Basketball
ServerId                : 17ba4d76bfad44d68b835a4dc47a464b
Id                      : 351648
DateCreated             : 2019-02-26T05:52:38.0000000+00:00
SortName                : college basketball  columbia at brown
ChannelId               : 319829
Overview                : From Pizzitola Memorial Sports Center in Providence, 
                          R.I.
Taglines                : {}
Genres                  : {Basketball}
RunTimeTicks            : 71999995904
ProviderIds             : @{SeriesZap2It=EP03061791}
ParentId                : 319829
Type                    : Program
Studios                 : {}
GenreItems              : {@{Name=Basketball; Id=46341}}
PrimaryImageAspectRatio : 0.666666666666667
ImageTags               : @{Primary=ded15045da42cc4add5ae19bc78c0c91}
BackdropImageTags       : {}
MediaType               : Video
EndDate                 : 2019-03-02T12:00:00.0000000+00:00
StartDate               : 2019-03-02T10:00:00.0000000+00:00
IsNew                   : True
EpisodeTitle            : Columbia at Brown
IsSports                : True
IsSeries                : True

Channel Info

Name              : NESNHD
ServerId          : 17ba4d76bfad44d68b835a4dc47a464b
Id                : 319829
Number            : 1342
ChannelNumber     : 1342
IsFolder          : False
Type              : TvChannel
ImageTags         : @{Primary=2d3f86fc6c62b0a4545b872b74884b22}
BackdropImageTags : {}
MediaType         : Video
CurrentProgram    : @{Name=UMass Sports Insider; 
                    ServerId=17ba4d76bfad44d68b835a4dc47a464b; Id=327164; 
                    PremiereDate=2011-08-26T04:00:00.0000000+00:00; 
                    ChannelId=319829; RunTimeTicks=17999998976; 
                    ProductionYear=2011; Type=Program; ImageTags=; 
                    BackdropImageTags=System.Object[]; MediaType=Video; 
                    EndDate=2019-02-27T02:30:00.0000000+00:00; 
                    StartDate=2019-02-27T02:00:00.0000000+00:00; 
                    IsRepeat=True; IsSeries=True}
Edited by jrhessey
Link to comment
Share on other sites

jrhessey

Never mind, I figured it out when I found the JOIN-OBJECT script.  I'm a database guy, that was by far the easiest command I had to figure out... lol!  

Link to comment
Share on other sites

jrhessey

Is there any chance that some of this data is filled from another data source like zap2it?  I'm having a hard time finding some values like productionyear (1992), indexnumber (19), IndexNumber (7), and a few others. I'm not actually recording Golden Girls...  It was the closest one that I KNEW had an old production year...  lol!

{
  "Status": "New",
  "RunTimeTicks": 18000000000,
  "ProgramInfo": {
    "Name": "The Golden Girls",
    "ServerId": "17ba4d76bfad44d68b835a4dc47a464b",
    "Id": "318969",
    "Etag": "bb2c343d38e2282b6267687476c5866d",
    "DateCreated": "2019-02-26T05:52:10.0000000+00:00",
    "CanDelete": false,
    "CanDownload": false,
    "SortName": "golden girls  journey to center of attention",
    "ExternalUrls": [],
    "OfficialRating": "TV-PG",
    "ChannelId": "74835",
    "ChannelName": "HALLHD",
    "Overview": "Dorothy replaces Blanche as the center of attention for the men at Blanche's favorite nightspot.",
    "Taglines": [],
    "Genres": [
      "Sitcom"
    ],
    "RunTimeTicks": 17999998976,
    "ProductionYear": 1992,
    "ChannelNumber": "1113",
    "IndexNumber": 19,
    "ParentIndexNumber": 7,
    "RemoteTrailers": [],
    "ProviderIds": {
      "SeriesZap2It": "EP00017476"
    },
    "ParentId": "74835",
    "Type": "Program",
    "Studios": [],
    "GenreItems": [
      {
        "Name": "Sitcom",
        "Id": 773
      }
    ],
    "DisplayPreferencesId": "8cab5e5f60ae4830c47f6431bbe4c3cb",
    "Status": "New",
    "Tags": [
      "Series"
    ],
    "PrimaryImageAspectRatio": 0.666666666666667,
    "ImageTags": {
      "Primary": "58a8a948607367fef31ae93ff2709be4",
      "Thumb": "a92df0f4a80678080054cf2a6eb3e80c"
    },
    "BackdropImageTags": [],
    "MediaType": "Video",
    "EndDate": "2019-02-27T05:30:00.0000000+00:00",
    "LockedFields": [],
    "LockData": false,
    "Width": 1280,
    "Height": 720,
    "ChannelPrimaryImageTag": "72ab49a9b30550add6ae5e565c7487f1",
    "StartDate": "2019-02-27T05:00:00.0000000+00:00",
    "EpisodeTitle": "Journey to the Center of Attention",
    "IsSeries": true,
    "TimerId": "85cd6bef9dcd4d22b71d6738957fc817"
  },
  "Id": "85cd6bef9dcd4d22b71d6738957fc817",
  "Type": "Timer",
  "ServerId": "17ba4d76bfad44d68b835a4dc47a464b",
  "ExternalId": "85cd6bef9dcd4d22b71d6738957fc817",
  "ChannelId": "74835",
  "ExternalChannelId": "hdhr_1113",
  "ChannelName": "HALLHD",
  "ChannelPrimaryImageTag": "72ab49a9b30550add6ae5e565c7487f1",
  "ProgramId": "318969",
  "ExternalProgramId": "EP000174760155T636868404000000000C66268_hdhr_1113",
  "Name": "The Golden Girls",
  "Overview": "Dorothy replaces Blanche as the center of attention for the men at Blanche's favorite nightspot.",
  "StartDate": "2019-02-27T05:00:00.0000000Z",
  "EndDate": "2019-02-27T05:30:00.0000000Z",
  "ServiceName": "Emby",
  "Priority": 0,
  "PrePaddingSeconds": 120,
  "PostPaddingSeconds": 120,
  "IsPrePaddingRequired": false,
  "IsPostPaddingRequired": false,
  "KeepUntil": "UntilDeleted"
}
Link to comment
Share on other sites

PenkethBoy

ProductionYear = Year in Metadata Manager = Year first Aired (IIRC) in this case

IndexNumber 19 = episode number

ParentIndexNumber7 = season 7

 

Emby is using your epg source to fill in this data and create the record (for each show) when the guide is refreshed

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...