Jump to content

Get physical path from an Item


djsumdog

Recommended Posts

djsumdog

This seems so incredibly basic and I must just be missing it. I've looking through the swagger-ui and I can get all the movies in a library using the following:

import requests

api_key = '***'
host = 'http://localhost:8096'
resp = requests.get(f'{host}/emby/Items', params={'api_key': api_key, 'Recursive': True})
all_items = resp.json()
movies = [i for i in all_items['Items'] if i['Type'] == 'Movie']
print(movies[0])

{'Name': "Pirates of the Caribbean: Dead Man's Chest",
 'ServerId': 'e9034df684e04338aea459a78044863c',
 'Id': '7',
 'RunTimeTicks': 101101440000,
 'IsFolder': False,
 'Type': 'Movie',
 'ImageTags': {'Primary': 'a3341ace4a1bda5505d264823f3954c1',
  'Logo': '3cd8ab491c746dd73fad521fbf4d63cf',
  'Thumb': '886d961bb76e20c6e348ec363288f447'},
 'BackdropImageTags': ['692cc5805115be0eb24fbd6d80f2c251'],
 'MediaType': 'Video'}

How do I get either the filename or the fullpath to the file (either would work for me). I tried

resp = requests.get(f'{host}/emby/Items', params={'api_key': api_key, 'Ids':7})

but that just gives me back the same data from my earlier call. I see there is a /Library/PhysicalPaths call, but that's just for the roots of the libraries. I've read others using /Items/{Id}/DeleteInfo, the get the path, but if I run /Items/7/DeleteInfo, I get a 500 error (is it expecting the Item ID from /Items or is that a different ID?)

Link to comment
Share on other sites

roaku

I use:

/Items/1799/PlaybackInfo?api_key={apikey}

Its response for a movie group with two versions looks like:

 

{
  "MediaSources": [
    {
      "Protocol": "File",
      "Id": "11501e8258cd03c04307eb2a613894d3",
      "Path": "../Alien (1979)/Alien (1979) - Directors Cut.mkv",
      "Type": "Default",
      "Container": "mkv",
      "Size": 8767806126,
      "Name": "Directors Cut",
      "IsRemote": false,
      "RunTimeTicks": 69499310000,
      "SupportsTranscoding": true,
      "SupportsDirectStream": true,
      "SupportsDirectPlay": true,
      "IsInfiniteStream": false,
      "RequiresOpening": false,
      "RequiresClosing": false,
      "RequiresLooping": false,
      "SupportsProbing": false,
      "MediaStreams": [
        {
          "Codec": "h264",
          "Language": "eng",
          "ColorTransfer": "bt709",
          "ColorPrimaries": "bt709",
          "ColorSpace": "bt709",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1001/48000",
          "VideoRange": "SDR",
          "DisplayTitle": "1080p H264",
          "DisplayLanguage": "English",
          "NalLengthSize": "4",
          "IsInterlaced": false,
          "IsAVC": true,
          "BitRate": 10092538,
          "BitDepth": 8,
          "RefFrames": 1,
          "IsDefault": true,
          "IsForced": false,
          "Height": 816,
          "Width": 1920,
          "AverageFrameRate": 23.976025,
          "RealFrameRate": 23.976025,
          "Profile": "High",
          "Type": "Video",
          "AspectRatio": "40:17",
          "Index": 0,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File",
          "PixelFormat": "yuv420p",
          "Level": 40,
          "IsAnamorphic": false
        },
        {
          "Codec": "dts",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Original",
          "DisplayTitle": "English Original",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "5.1",
          "BitDepth": 24,
          "Channels": 6,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "DTS-HD MA",
          "Type": "Audio",
          "Index": 1,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "aac",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Fallback",
          "DisplayTitle": "English Fallback",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "5.1",
          "BitRate": 320000,
          "Channels": 6,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "LC",
          "Type": "Audio",
          "Index": 2,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "aac",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Commentary",
          "DisplayTitle": "English Commentary",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "stereo",
          "BitRate": 192000,
          "Channels": 2,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "LC",
          "Type": "Audio",
          "Index": 3,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "mjpeg",
          "ColorSpace": "bt470bg",
          "TimeBase": "1/90000",
          "CodecTimeBase": "0/1",
          "IsInterlaced": false,
          "BitDepth": 8,
          "RefFrames": 1,
          "IsDefault": false,
          "IsForced": false,
          "Height": 3000,
          "Width": 2000,
          "RealFrameRate": 90000,
          "Profile": "Progressive",
          "Type": "EmbeddedImage",
          "AspectRatio": "2:3",
          "Index": 4,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File",
          "PixelFormat": "yuvj420p",
          "Level": -99,
          "IsAnamorphic": false
        }
      ],
      "Formats": [],
      "Bitrate": 10092538,
      "RequiredHttpHeaders": {},
      "ReadAtNativeFramerate": false
    },
    {
      "Protocol": "File",
      "Id": "cdca2617de5a67a9be39fad94b4b508c",
      "Path": "../Alien (1979)/Alien (1979).mkv",
      "Type": "Grouping",
      "Container": "mkv",
      "Size": 9773089475,
      "Name": "Alien",
      "IsRemote": false,
      "RunTimeTicks": 69976530000,
      "SupportsTranscoding": true,
      "SupportsDirectStream": true,
      "SupportsDirectPlay": true,
      "IsInfiniteStream": false,
      "RequiresOpening": false,
      "RequiresClosing": false,
      "RequiresLooping": false,
      "SupportsProbing": false,
      "MediaStreams": [
        {
          "Codec": "h264",
          "Language": "eng",
          "ColorTransfer": "bt709",
          "ColorPrimaries": "bt709",
          "ColorSpace": "bt709",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1001/48000",
          "VideoRange": "SDR",
          "DisplayTitle": "1080p H264",
          "DisplayLanguage": "English",
          "NalLengthSize": "4",
          "IsInterlaced": false,
          "IsAVC": true,
          "BitRate": 11172991,
          "BitDepth": 8,
          "RefFrames": 1,
          "IsDefault": true,
          "IsForced": false,
          "Height": 816,
          "Width": 1920,
          "AverageFrameRate": 23.976025,
          "RealFrameRate": 23.976025,
          "Profile": "High",
          "Type": "Video",
          "AspectRatio": "40:17",
          "Index": 0,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File",
          "PixelFormat": "yuv420p",
          "Level": 40,
          "IsAnamorphic": false
        },
        {
          "Codec": "dts",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Original",
          "DisplayTitle": "English Original",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "5.1",
          "BitDepth": 24,
          "Channels": 6,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "DTS-HD MA",
          "Type": "Audio",
          "Index": 1,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "aac",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Fallback",
          "DisplayTitle": "English Fallback",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "5.1",
          "BitRate": 320000,
          "Channels": 6,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "LC",
          "Type": "Audio",
          "Index": 2,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "aac",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Commentary 1",
          "DisplayTitle": "English Commentary 1",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "stereo",
          "BitRate": 192000,
          "Channels": 2,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "LC",
          "Type": "Audio",
          "Index": 3,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "aac",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Commentary 2",
          "DisplayTitle": "English Commentary 2",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "stereo",
          "BitRate": 192000,
          "Channels": 2,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "LC",
          "Type": "Audio",
          "Index": 4,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "aac",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Final Score",
          "DisplayTitle": "English Final Score",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "5.1",
          "BitRate": 320000,
          "Channels": 6,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "LC",
          "Type": "Audio",
          "Index": 5,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "aac",
          "Language": "eng",
          "TimeBase": "1/1000",
          "CodecTimeBase": "1/48000",
          "Title": "Original Score",
          "DisplayTitle": "English Original Score",
          "DisplayLanguage": "English",
          "IsInterlaced": false,
          "ChannelLayout": "5.1",
          "BitRate": 320000,
          "Channels": 6,
          "SampleRate": 48000,
          "IsDefault": false,
          "IsForced": false,
          "Profile": "LC",
          "Type": "Audio",
          "Index": 6,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File"
        },
        {
          "Codec": "mjpeg",
          "ColorSpace": "bt470bg",
          "TimeBase": "1/90000",
          "CodecTimeBase": "0/1",
          "IsInterlaced": false,
          "BitDepth": 8,
          "RefFrames": 1,
          "IsDefault": false,
          "IsForced": false,
          "Height": 3000,
          "Width": 2000,
          "RealFrameRate": 90000,
          "Profile": "Progressive",
          "Type": "EmbeddedImage",
          "AspectRatio": "2:3",
          "Index": 7,
          "IsExternal": false,
          "IsTextSubtitleStream": false,
          "SupportsExternalStream": false,
          "Protocol": "File",
          "PixelFormat": "yuvj420p",
          "Level": -99,
          "IsAnamorphic": false
        }
      ],
      "Formats": [],
      "Bitrate": 11172991,
      "RequiredHttpHeaders": {},
      "ReadAtNativeFramerate": false
    }
  ],
  "PlaySessionId": "093001071bd1483aa4bc4626b44009b6"
}

 

Edited by roaku
Link to comment
Share on other sites

roaku

If you need the path for more than one item, you can add 'Path' to the 'fields' parameter like this:

Items?api_key={api_key}&Recursive=true&IncludeItemTypes=Movie&Fields=Path,TagLines,Overview,PremiereDate,Genres,MediaStreams&SortBy=Name&SortOrder=Ascending

The catch is that if you have multi-version movies, Emby only returns the path for what it considers to be the primary version of that movie grouping.

Edited by roaku
Link to comment
Share on other sites

djsumdog

ah cool! Thanks both of you! It looks like I've got quite a few groups, so I'll likely pull them individually, but it's good to know I can add more fields to the /Items listing.

 

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