Jump to content


Photo

Find 'IsWatched' episodes in a specific directory?


  • Please log in to reply
25 replies to this topic

#1 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 21 August 2018 - 05:25 PM

I have tried a couple things, but to be honest, I'm not a developer!  I am trying to pull up TV episodes that are watched in my Recorded TV folder (let's say C:\Recorded TV).  I can authenticate, but I can't figure out how to actually get the info that I need.

 

Eventually, the idea I want to implement is that anything that has been watched get's automatically compressed and moved to an alternate file location.  BUT, not until it has been watched.  

 

I already have the VBS script that compresses the video, I just need to find a way to tell if a specific file has been watched or not.

 

Can anyone help?



#2 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3367 posts
  • Local time: 02:21 PM
  • LocationWarrington,UK

Posted 21 August 2018 - 06:37 PM

$embyServerUrl + "/emby/users/" + $User.User.Id + "/items?Recursive=true&IncludeItemTypes=Episode&IsPlayed=True" + "&api_key=" + $User.AccessToken

 

this is from Powershell but if you are using vbs not that hard to follow

 

it will return a json object with some basic info about the episodes that have been played - across all TV libraries



#3 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 21 August 2018 - 06:44 PM

Thanks!  I'm getting closer.  Is it possible to restrict it to the 'Recordings' library?



#4 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3367 posts
  • Local time: 02:21 PM
  • LocationWarrington,UK

Posted 21 August 2018 - 06:47 PM

use the library id as ParentID=<library ID>


Edited by PenkethBoy, 21 August 2018 - 06:52 PM.


#5 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3367 posts
  • Local time: 02:21 PM
  • LocationWarrington,UK

Posted 21 August 2018 - 06:53 PM

If you wait a couple of weeks i will be posting a reporting script which will give you all the data you need and more



#6 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 21 August 2018 - 06:55 PM

use the library id as ParentID=<library ID>

I tried this, but then realized that I don't know how to find the library ID.  I tried Recordings, but it didn't seem to work.  I'm slogging through the Swagger UI page and trying different combinations, but still can't get it to work.

 

If you wait a couple of weeks i will be posting a reporting script which will give you all the data you need and more

I can probably wait, but was hoping to test ASAP, since I just purchased a month, and am hoping to replicate the functionality I already have using JRiver.

 

I do very much appreciate the help!!



#7 speechles ONLINE  

speechles

    Advanced Member

  • App Developer
  • 5269 posts
  • Local time: 06:21 AM

Posted 21 August 2018 - 06:59 PM

You might want to "&sortby=datecreated,sortname&sortorder=descending" at the end In that way you can sort of cache in your script the last watched item-title and it's item-id into variables. Then when you read the next json package it can work to give you an idea of where to stop when parsing the json on down from the last. So you don't parse two fields twice sort of thing.

 

 

$embyServerUrl + "/emby/users/" + $User.User.Id + "/Views"

 

That would get the root of the entire library including id's.


Edited by speechles, 21 August 2018 - 07:08 PM.


#8 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3367 posts
  • Local time: 02:21 PM
  • LocationWarrington,UK

Posted 21 August 2018 - 07:42 PM

the library id is in the url of the library home page

 

it depends which version of the server you are using as Luke is making major changes at the moment - it might say topParentID=xxxx

 

but its parentID in the api url



#9 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3367 posts
  • Local time: 02:21 PM
  • LocationWarrington,UK

Posted 21 August 2018 - 07:44 PM

"I already have the VBS script that compresses the video"

 

Have you tried the convert/sync option within Emby?



#10 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 21 August 2018 - 09:09 PM

"I already have the VBS script that compresses the video"

 

Have you tried the convert/sync option within Emby?

No, but I didn't see an option to only compress after I had watched it.  Did I miss it?



#11 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 135879 posts
  • Local time: 09:21 AM

Posted 21 August 2018 - 11:16 PM

Have you explored our convert media feature?



#12 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 22 August 2018 - 12:40 AM

Have you explored our convert media feature?

see one post above.  I only want to convert (and delete the original) after watching in HD.  This is for archive purposes, and I want it to be automated.



#13 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 135879 posts
  • Local time: 09:21 AM

Posted 22 August 2018 - 09:18 AM

Sounds like a good fit then.

#14 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 08 September 2019 - 05:36 PM

So I am back on this again.  Really wanting to get this to work, but I just can't for whatever reason.  If I do this:

http://10.1.0.122:8096/emby/items?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&Recursive=true&IncludeItemTypes=Episode

I get a list of all items.  However, as soon as I add &IsPlayed=True, it throws an error.  Here is what I tried:

http://10.1.0.122:8096/emby/items?api_key=xxxxxxxxxxxxxxxxxxxxxxxxxxx&Recursive=true&IncludeItemTypes=Episode&IsPlayed=True

What am I doing wrong? 

 

Then, even if I get the list, I have to figure out in vbs how to parse JSON in VBS, and I don't believe that is a simple task.


Edited by muzicman0, 09 September 2019 - 10:03 AM.


#15 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 135879 posts
  • Local time: 09:21 AM

Posted 09 September 2019 - 01:15 PM

What error?



#16 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 09 September 2019 - 01:23 PM

I remoted in and tried it to make sure I get the exact error.  The error is:

 

Exception of type 'SQLitePCL.pretty.SQLiteException' was thrown.

 

Also, assuming I can get this to work, is there a way that the path to the file can be included in the output?  When I look at the items (without the filter for 'played'), path isn't included.



#17 PenkethBoy OFFLINE  

PenkethBoy

    Advanced Member

  • Members
  • 3367 posts
  • Local time: 02:21 PM
  • LocationWarrington,UK

Posted 09 September 2019 - 04:23 PM

I just tried this (beta Server)

 

and it works - guess as you are not adding the /users/<userid> thats probably it - did not test that

 

anyway this works

".../emby/users/" + $User.User.Id + "/items?Fields=Path&Recursive=true&IncludeItemTypes=Episode&IsPlayed=True" + "&api_key=" + $User.AccessToken

Adding Fields=Path will return the path to the item if you need other Fields the field names are comma delimited e.g. Fields=Path,Genres,ProviderIds etc etc

 

Example output

{
    "Items":  [
                  {
                      "Name":  "Jasper + Chef",
                      "ServerId":  "393d783c30484015a24645f7844060b4",
                      "Id":  "884",
                      "Path":  "F:\\EmbyTest\\TVTesting\\Alan Partridge Mid Morning Matters\\Season 2\\Alan Partridge\u0027s Mid Morning Matters - S02E04 - Episode 4.ts",
                      "RunTimeTicks":  16001340416,
                      "IndexNumber":  4,
                      "ParentIndexNumber":  2,
                      "IsFolder":  false,
                      "Type":  "Episode",
                      "ParentLogoItemId":  "867",
                      "ParentBackdropItemId":  "867",
                      "ParentBackdropImageTags":  [
                                                      "8b09d6b2705e17f0362eda8c3bf0541e",
                                                      "7390971789f97cc5797acaad92cbaa9d",
                                                      "65df2fb83a3084a3d39b04366949e80c",
                                                      "23a6f33b8b72907526595b78970d5b35"
                                                  ],
                      "UserData":  {
                                       "PlaybackPositionTicks":  0,
                                       "PlayCount":  1,
                                       "IsFavorite":  false,
                                       "LastPlayedDate":  "2019-09-09T20:11:34.0000000+00:00",
                                       "Played":  true
                                   },
                      "SeriesName":  "Alan Partridge\u0027s Mid Morning Matters",
                      "SeriesId":  "867",
                      "SeasonId":  "883",
                      "SeriesPrimaryImageTag":  "0d26d4afaf9e37fa7ba265667f87deb9",
                      "SeasonName":  "Season 2",
                      "ImageTags":  {
                                        "Primary":  "59d1c3b87ec9afbaf42e664d7950af47"
                                    },
                      "BackdropImageTags":  [

                                            ],
                      "ParentLogoImageTag":  "8e89c5c81fe8788b872dac62b0807a12",
                      "ParentThumbItemId":  "867",
                      "ParentThumbImageTag":  "6084f185aac52a90ea088e2281d3e7a8",
                      "MediaType":  "Video"
                  }
              ],
    "TotalRecordCount":  1
}

If VBS does not have an easy way to read JSON - then might be worth moving to a more modern language - i happen to use Powershell and that can read and write json files with no problem - as i suspect can Visual Studio if thats more to your liking etc etc



#18 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 09 September 2019 - 05:19 PM

I wonder if it just doesn't work in a browser.  I tried:

 

http://10.1.0.122:80...xxxxxxxxxxxxxxx

 

and now it says:

 

Input string was not in a correct format.

 

I'll try learning JSON in powershell.  I have done some basic stuff that way, but I haven't actually done much programming since Visual Basic 6!!  Mostly just scripting in VBS and VBA.

 

I'll try to make a powershell script with your example.



#19 muzicman0 OFFLINE  

muzicman0

    Advanced Member

  • Members
  • 32 posts
  • Local time: 06:21 AM

Posted 09 September 2019 - 05:27 PM

I am confused by this:

 

$User.User.Id

 

Is that just my username in a variable, or is that an object that has multiple properties.  If an object, how do I use it? 

 

I really do appreciate all the help!



#20 Luke OFFLINE  

Luke

    System Architect

  • Administrators
  • 135879 posts
  • Local time: 09:21 AM

Posted 09 September 2019 - 05:38 PM

Have you checked out our Api Wiki ?






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users