Jump to content

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


Recommended Posts

Andy6666

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

 

Link to post
Share on other sites
Luke

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

  • Haha 1
Link to post
Share on other sites
Andy6666

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.

Link to post
Share on other sites
Andy6666
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.

Link to post
Share on other sites
roaku

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

 

Link to post
Share on other sites
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
Link to post
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...