Jump to content

Is there any way to query for complete file path of a TV episode?


Go to solution Solved by Cheesegeezer,

Recommended Posts

Posted

The title says it all.  I have "Type: "Episode" item data and I'd like to know the complete video file path.  Is this possible?

Posted

Hi, have you checked item.Path?

Posted

In my comments I have a old result of item.Path, but I'm not getting it now.  Also, it was only a path to the show, not an episode file, like *.mkv.

Posted
1 hour ago, mchahn said:

In my comments I have a old result of item.Path, but I'm not getting it now.  Also, it was only a path to the show, not an episode file, like *.mkv.

What kind of item is it, where does it come from?

You could try the "Metadata Explorer" plugin to see which data exists in Emby's DataBase

Posted

I can't find it in the catalog so I'll assume it requires beta.  I went to downloads page and there was no option for beta.  Where can I download beta?

Posted
15 minutes ago, mchahn said:

I can't find it in the catalog so I'll assume it requires beta.  I went to downloads page and there was no option for beta.  Where can I download beta?

Which platform?

Cheesegeezer
Posted
14 hours ago, mchahn said:

The title says it all.  I have "Type: "Episode" item data and I'd like to know the complete video file path.  Is this possible?

 

//Get The Items in your library.

BaseItem[] _itemsList;
int _itemsCount;
private async Task GetItemIdInEmbyLibraries()
{
			try
            {
                Log.Info("Getting Folder(s) Items");

                var queryList = new InternalItemsQuery
                {
                    Recursive = true,
                    IncludeItemTypes = new[] {nameof(Episode)},
                    MediaTypes = new[] { "Video" },
                    IsVirtualItem = false,
                };

                _itemsList = LibraryManager.GetItemList(queryList);
                _itemsCount = _itemsList.Length;
                Log.Info("Total No. of items in Library {0}", _itemsCount.ToString());
            }
            catch (Exception ex)
            {
                Log.Error("No Lib Items Found in Library");
                Log.Error(ex.ToString());
            }
}

 

Then you can do what you want with the _itemsList


foreach (var item in _itemsList)
{
  try
  {
         
    var stopWatch = new Stopwatch();
    stopWatch.Start();

          Log.Info("PROCESSING OF  " + item.Name + "  HAS STARTED");
          Log.Info("Item FilePath = {0} ", item.Path.ToString());
    	  Log.Info("Item Containing Folder = {0} ", item.ContainingFolderPath.ToString());
          //Do what you need here,
    	  // you can use item.Path or item.ContainingFolderPath
		  //you can also use Emby's IFileSystem and use GetFileNameWithoutExtension if you need to
    
          Log.Info("PROCESSING OF {0} HAS COMPLETED", item.Name);
    
          _totalProgress++;
          double dprogress = 100 * (_totalProgress / _totalItems);
          progress.Report(dprogress);

          stopWatch.Stop();
          Log.Debug("Processing for {0} and took {1} milliseconds", item.Name,
                    (stopWatch.ElapsedMilliseconds).ToString());        
      }
  catch(Exception ex)
  {
    Log.Error("Error Processing Episode" + ex.ToString());
  }
}

 

 

Posted
10 hours ago, softworkz said:

Which platform?

Ubuntu

Posted

Thanks @Cheesegeezer.  It appears that is C++ in some kind of emby plugin environment, correct?   I'm using the web-based API so I can't really take advantage of your code.  I hope you didn't take the trouble to write any code just for me.  🙂

Cheesegeezer
Posted
11 minutes ago, mchahn said:

Thanks @Cheesegeezer.  It appears that is C++ in some kind of emby plugin environment, correct?   I'm using the web-based API so I can't really take advantage of your code.  I hope you didn't take the trouble to write any code just for me.  🙂

No worries,   I didn't write it specially, it's used a lot on my plugins.

Can you not take advantage of the ApiClient in your Javascript and call this into a variable.

async function getEpisodes() {
            return await ApiClient.getJSON(ApiClient.getUrl(
                'Items?ExcludeLocationTypes=Virtual&Recursive=true&IncludeItemTypes=Episode));
        }

 

Posted
7 minutes ago, Cheesegeezer said:
ApiClient.getUrl

I don't know any way to do this in the web api but it may be possible.  Is there a way to view the code for getUrl?  I have to walk my way through the various level of database items.  As I said in my first post I can get a record containg "type":"episode" but that record doesn't have any URL.

Cheesegeezer
Posted
23 minutes ago, mchahn said:

I don't know any way to do this in the web api but it may be possible.  Is there a way to view the code for getUrl?  I have to walk my way through the various level of database items.  As I said in my first post I can get a record containg "type":"episode" but that record doesn't have any URL.

Ahhhh right, so you are literally just plugging in a call in the address bar of a browser to get information?

So are you scripting? or are you building an application or what?

 

Posted
12 minutes ago, Cheesegeezer said:

So are you scripting?

Yes, from a web app.  The JS in the web page makes a call like "http://<hostname>:8096/emby/Users/894c752d448f45a3a1260ccaabd0adff/Items/?ParentId=&X-Emby-Token=<secret>".  This can be put into a browser web address for testing.  This is the result of using that URL in the browser (using the code function in this post removed the indents pasting).

{
    "item": {
        "Name": "Episode 6",
        "ServerId": "ae3349983dbe45d9aa1d317a7753483e",
        "Id": "4693966",
        "RunTimeTicks": 34444160000,
        "IndexNumber": 6,
        "ParentIndexNumber": 1,
        "IsFolder": false,
        "Type": "Episode",
        "ParentBackdropItemId": "4693962",
        "ParentBackdropImageTags": [
            "422d8fec80b260d654ee657d442065c0"
        ],
        "UserData": {
            "PlaybackPositionTicks": 0,
            "PlayCount": 1,
            "IsFavorite": false,
            "LastPlayedDate": "2022-07-03T03:34:28.0000000Z",
            "Played": true
        },
        "SeriesName": "Chloe",
        "SeriesId": "4693962",
        "SeasonId": "4693964",
        "SeriesPrimaryImageTag": "d8b85615fedfcfb05ff755b1bbcf9ec2",
        "SeasonName": "Season 1",
        "ImageTags": {
            "Primary": "b8a48ad32271beadf28484d330aa42e0"
        },
        "BackdropImageTags": [],
        "ParentThumbItemId": "4693962",
        "ParentThumbImageTag": "c0d51f0b247037cb7ee14c59ac83e10c",
        "MediaType": "Video"
    }
}

Note that the url doesn't have "Fields=" param so all fields are returned.  I would like the Path field to appear but it doesn't.

Posted

Can @softworkz or anyone else tell me how to download the beta server for ubuntu linux?

Cheesegeezer
Posted
42 minutes ago, mchahn said:

Yes, from a web app.  The JS in the web page makes a call like "http://<hostname>:8096/emby/Users/894c752d448f45a3a1260ccaabd0adff/Items/?ParentId=&X-Emby-Token=<secret>".  This can be put into a browser web address for testing.  This is the result of using that URL in the browser (using the code function in this post removed the indents pasting).

{
    "item": {
        "Name": "Episode 6",
        "ServerId": "ae3349983dbe45d9aa1d317a7753483e",
        "Id": "4693966",
        "RunTimeTicks": 34444160000,
        "IndexNumber": 6,
        "ParentIndexNumber": 1,
        "IsFolder": false,
        "Type": "Episode",
        "ParentBackdropItemId": "4693962",
        "ParentBackdropImageTags": [
            "422d8fec80b260d654ee657d442065c0"
        ],
        "UserData": {
            "PlaybackPositionTicks": 0,
            "PlayCount": 1,
            "IsFavorite": false,
            "LastPlayedDate": "2022-07-03T03:34:28.0000000Z",
            "Played": true
        },
        "SeriesName": "Chloe",
        "SeriesId": "4693962",
        "SeasonId": "4693964",
        "SeriesPrimaryImageTag": "d8b85615fedfcfb05ff755b1bbcf9ec2",
        "SeasonName": "Season 1",
        "ImageTags": {
            "Primary": "b8a48ad32271beadf28484d330aa42e0"
        },
        "BackdropImageTags": [],
        "ParentThumbItemId": "4693962",
        "ParentThumbImageTag": "c0d51f0b247037cb7ee14c59ac83e10c",
        "MediaType": "Video"
    }
}

Note that the url doesn't have "Fields=" param so all fields are returned.  I would like the Path field to appear but it doesn't.

All the fields are not returned. You need to specify what you need in the request.  I started making a Web Client and i had to add overview, communityRating, etc in order to return that info to display. 
 

have you actually done a

console.log(“EpisodeInfo: “, episodeVariable);

to see what is returned? 
 

ill dig out my code for you from it. Out at the moment. So will be a wee while 

  • Solution
Cheesegeezer
Posted

ok so here's what i used to get item path in the variable.  This is what i used for what i needed you can remove what you need

192.168.0.117:8096/emby/Users/{userId}/Items/Latest?Limit={itemLimit}&ParentId={folderId}&Fields=Taglines%2CBudget%2CCommunityRating%2COverview%2CMediaStreams&api_key={AuthToken};

But essentially what you are looking for is the container that holds MediaSources in... this will give you your video path, etc

image.png.ec6d7e18065b7484d91efcfee1b31450.png

 

  • Like 1
Cheesegeezer
Posted

What you need is this actually... just tested

http://localhost:8096/emby/Users/{currUserId}/Items?Fields=MediaStreams&EnableImages=true&EnableUserData=true&Ids=475746&api_key={AuthToken}
// RETURNS THIS

{
  "Items": [
    {
      "Name": "Space Chicken",
      "ServerId": "8da294d223d1427983f791b4cdb051e5",
      "Id": "475746",
      "Container": "mkv",
      "MediaSources": [
        {
          "Protocol": "File",
          "Id": "ca99ab49539ac5672254441605cbbc68",
          "Path": "D:\\Emby_Test\\TV Shows\\House\\Season 02\\House - S02E01E02.mkv",
          "Type": "Default",
          "Container": "mkv",
          "Size": 297031408,
          "Name": "House - S02E01E02",
          "IsRemote": false,
          "RunTimeTicks": 25357350000,
          "SupportsTranscoding": true,
          "SupportsDirectStream": true,
          "SupportsDirectPlay": true,
          "IsInfiniteStream": false,
          "RequiresOpening": false,
          "RequiresClosing": false,
          "RequiresLooping": false,
          "SupportsProbing": false,
          "MediaStreams": [
            {
              "Codec": "mpeg4",
              "CodecTag": "XVID",
              "TimeBase": "1/1000",
              "Title": "SD MPEG-4 Visual [0.7Mb/s]",
              "VideoRange": "SDR",
              "DisplayTitle": "SD MPEG-4 Visual [0.7Mb/s]",
              "IsInterlaced": false,
              "BitRate": 937105,
              "BitDepth": 8,
              "RefFrames": 1,
              "IsDefault": true,
              "IsForced": false,
              "Height": 480,
              "Width": 720,
              "AverageFrameRate": 29.97,
              "RealFrameRate": 29.97,
              "Profile": "Advanced Simple Profile",
              "Type": "Video",
              "AspectRatio": "1.5:1",
              "Index": 0,
              "IsExternal": false,
              "IsTextSubtitleStream": false,
              "SupportsExternalStream": false,
              "Protocol": "File",
              "PixelFormat": "yuv420p",
              "Level": 5,
              "IsAnamorphic": false,
              "AttachmentSize": 0
            },
            {
              "Codec": "mp3",
              "TimeBase": "1/1000",
              "Title": " 2.0 ",
              "DisplayTitle": "Und  2.0 ",
              "IsInterlaced": false,
              "ChannelLayout": "stereo",
              "BitRate": 192000,
              "Channels": 2,
              "SampleRate": 44100,
              "IsDefault": true,
              "IsForced": false,
              "Type": "Audio",
              "Index": 1,
              "IsExternal": false,
              "IsTextSubtitleStream": false,
              "SupportsExternalStream": false,
              "Protocol": "File",
              "AttachmentSize": 0
            }
          ],
          "Formats": [],
          "Bitrate": 937105,
          "RequiredHttpHeaders": {},
          "ReadAtNativeFramerate": false,
          "DefaultAudioStreamIndex": 1,
          "DefaultSubtitleStreamIndex": -1
        }
      ],
      "RunTimeTicks": 25357350000,
      "Size": 297031408,
      "Bitrate": 937105,
      "IndexNumber": 1,
      "ParentIndexNumber": 2,
      "IsFolder": false,
      "Type": "Episode",
      "ParentLogoItemId": "287662",
      "ParentBackdropItemId": "287662",
      "ParentBackdropImageTags": [
        "ecb087239f10dff90e64e11decc359cd",
        "787c843eb3f13a3420d418c7048f77ba",
        "53cebe1738af8a1bf740c1126f14fefe"
      ],
      "UserData": {
        "PlayedPercentage": 29.94507793203943,
        "PlaybackPositionTicks": 7593278219,
        "PlayCount": 1,
        "IsFavorite": false,
        "LastPlayedDate": "2022-11-21T17:05:58.0000000Z",
        "Played": false
      },
      "SeriesName": "House",
      "SeriesId": "287662",
      "SeasonId": "475731",
      "SeriesPrimaryImageTag": "d3b1479be47a92fbc446447778bc3b82",
      "SeasonName": "Season 2",
      "MediaStreams": [
        {
          "Codec": "mpeg4",
          "CodecTag": "XVID",
          "TimeBase": "1/1000",
          "Title": "SD MPEG-4 Visual [0.7Mb/s]",
          "VideoRange": "SDR",
          "DisplayTitle": "SD MPEG-4 Visual [0.7Mb/s]",
          "IsInterlaced": false,
          "BitRate": 937105,
          "BitDepth": 8,
          "RefFrames": 1,
          "IsDefault": true,
          "IsForced": false,
          "Height": 480,
          "Width": 720,
          "AverageFrameRate": 29.97,
          "RealFrameRate": 29.97,
          "Profile": "Advanced Simple Profile",
          "Type": "Video",
          "AspectRatio": "1.5:1",
          "Index": 0,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File",
          "PixelFormat": "yuv420p",
          "Level": 5,
          "IsAnamorphic": false,
          "AttachmentSize": 0
        },
        {
          "Codec": "mp3",
          "TimeBase": "1/1000",
          "Title": " 2.0 ",
          "DisplayTitle": "Und  2.0 ",
          "IsInterlaced": false,
          "ChannelLayout": "stereo",
          "BitRate": 192000,
          "Channels": 2,
          "SampleRate": 44100,
          "IsDefault": true,
          "IsForced": false,
          "Type": "Audio",
          "Index": 1,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File",
          "AttachmentSize": 0
        }
      ],
      "ImageTags": {
        "Primary": "1d29a444931a106347a50213d74f1a42"
      },
      "BackdropImageTags": [],
      "ParentLogoImageTag": "92308b003ebccdeb2bdff1ba87b9b99b",
      "ParentThumbItemId": "287662",
      "ParentThumbImageTag": "6684e1694566f8d80a109eaed4c3a929",
      "MediaType": "Video"
    }
  ],
  "TotalRecordCount": 1
}

 

  • Like 2
Posted

Thank you , thank you.  That is exactly what I need.  I'm curious how you found out about the MediaSources field.  Just curious, don't go to any trouble.

Cheesegeezer
Posted
24 minutes ago, mchahn said:

Thank you , thank you.  That is exactly what I need.  I'm curious how you found out about the MediaSources field.  Just curious, don't go to any trouble.

i use it a lot in the c# plugins.  And by creating UI's i always need to get the mediastreams because they contain codec information which needs to be displayed. And ultimately base transcode decisions on the device against the codec info.

 

Posted

Thanks @Luke, @softworks, and @Cheesegeezer for taking the trouble to give awesome support.  I wish I could mark multiple posts as the solution.

  • Thanks 2

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...