Jump to content

how can I get the video file path in a plugin MetadataProvider Class


Recommended Posts

Andy6666
Posted

Hi, I want build a MetadataProvider  plugin to define some rules to read my file. I got a problem that I can't get the file full path in a Privider class.

My Class implements "IHasOrder, IRemoteMetadataProvider<Movie, MovieInfo>" 

So, How can I get the file full path so I can modify my file name rules.

 

thanks

 

Posted

Hi, what do you need the full file path for?

  • Haha 1
Andy6666
Posted

Hello, I know the naming convention of emby, but I have a lot of video files that are not named according to the naming convention of emby. For example, a/a.1080p.x264/a.1080p.x264.mkv many files are like this. In order to get better metadata, I modified an open source Douban plugin to make it more suitable for my existing file naming rules. I hope I can use the path in the plug-in to get the correct movie name, and then scrape the metadata to be more accurate.

Andy6666
Posted
37 minutes ago, Luke said:

Hi, what do you need the full file path for?

Hello, I know the naming convention of emby, but I have a lot of video files that are not named according to the naming convention of emby. For example, a/a.1080p.x264/a.1080p.x264.mkv many files are like this. In order to get better metadata, I modified an open source Douban plugin to make it more suitable for my existing file naming rules. I hope I can use the path in the plug-in to get the correct movie name, and then scrape the metadata to be more accurate.

Posted

I don't know the specifics of MetadataProvider, but if you have access to the movie as a BaseItem, you can get to the file path of the 'primary' movie file like this:

BaseItem.GetMediaStreams()[0].Path

  

Or, if you have a multi-version movie and need to check all versions, like this:

//item is a BaseItem you got from somewhere
List<MediaSourceInfo> mediaSources = item.GetMediaSources(true, false, _libraryManager.GetLibraryOptions(item));
  
if (mediaSources != null) {
	foreach (MediaSourceInfo mediaSourceInfo in mediaSources) {
  		if (mediaSourceInfo.Path != null) {
  				//do something with the path for that file
		}
	}
}

 

Andy6666
Posted (edited)
13 hours ago, roaku said:

I don't know the specifics of MetadataProvider, but if you have access to the movie as a BaseItem, you can get to the file path of the 'primary' movie file like this:


BaseItem.GetMediaStreams()[0].Path

  

Or, if you have a multi-version movie and need to check all versions, like this:


//item is a BaseItem you got from somewhere
List<MediaSourceInfo> mediaSources = item.GetMediaSources(true, false, _libraryManager.GetLibraryOptions(item));
  
if (mediaSources != null) {
	foreach (MediaSourceInfo mediaSourceInfo in mediaSources) {
  		if (mediaSourceInfo.Path != null) {
  				//do something with the path for that file
		}
	}
}

 

Thanks for your solution. I have a question that how can I have access to baseItem class?

my class is defined like following code:

public class MovieProvider : BaseProvider, IHasOrder,
        IRemoteMetadataProvider<Movie, MovieInfo>
          
// BaseProvider is a base class defined.
public abstract class BaseProvider

I try to get BaseItem from IRemoteMetadataProvider, but it didn't work. I notice Movie class is a son class of BaseItem, But I can't access, too.  Should I inherit the BaseItem Class? @roaku

Edited by Andy6666
Andy6666
Posted (edited)

Reply to someone using Quote button?  Can other people receive a notify? Sorry about lots of questions,  I'm a newer.  @Luke

Edited by Andy6666
  • 2 weeks later...
Posted

Ok, I suppose we could look at adding the Path in there.

  • 2 years later...
Posted

Hi, the function of obtaining video file path in the plugin has been implemented? Can you give some example code? @Luke

  • 2 weeks later...
Posted
On 5/14/2024 at 9:32 PM, koooo said:

Hi, the function of obtaining video file path in the plugin has been implemented? Can you give some example code? @Luke

Hi @koooocurious, what do you plan to use it for?

  • 4 weeks later...
Posted
On 5/24/2024 at 4:20 AM, Luke said:

Hi @koooocurious, what do you plan to use it for?

@Luke I have a collection of unique anime titles and I aim to develop a plugin that can parse season number and episode number correctly. Therefore, can retrieve the original path from MovieInfo/SeriesInfo/SeasonInfo/EpisodeInfo would be very useful.

Some example:

[Hachikuro Honey and Clover] I+II+SP
  |[Hachikuro Honey and Clover] I
     |[Hachikuro Honey and Clover] I-01.mp4 
  |[Hachikuro Honey and Clover] II
     |[Hachikuro Honey and Clover] II-01.mp4 

 

  • 1 month later...
Posted

OK we'll add this on the 4.9 beta channel. Thanks.

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