本文整理汇总了C#中MediaPortal.Plugins.MovingPictures.Database.DBMovieInfo.AddBackdropFromFile方法的典型用法代码示例。如果您正苦于以下问题:C# DBMovieInfo.AddBackdropFromFile方法的具体用法?C# DBMovieInfo.AddBackdropFromFile怎么用?C# DBMovieInfo.AddBackdropFromFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaPortal.Plugins.MovingPictures.Database.DBMovieInfo
的用法示例。
在下文中一共展示了DBMovieInfo.AddBackdropFromFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getBackdropsFromMovieFolder
// if flagged, check for backdrops in the movie folder based on the user defined pattern
private bool getBackdropsFromMovieFolder(DBMovieInfo movie)
{
// should never really happen, but if the database is corrupt,
// we dont want to crash, so just quit.
if (movie.LocalMedia.Count == 0)
return false;
bool found = false;
bool useMovieFolderBackdrops = MovingPicturesCore.Settings.SearchMovieFolderForBackdrops;
string pattern = MovingPicturesCore.Settings.MovieFolderBackdropFilenamePattern;
if (useMovieFolderBackdrops) {
List<string> movieFolderFilenames = getPossibleNamesFromPattern(pattern, movie);
foreach (string currFile in movieFolderFilenames) {
FileInfo newBackdrop = new FileInfo(Utility.GetMovieBaseDirectory(movie.LocalMedia[0].File.Directory).FullName + "\\" + currFile);
if (newBackdrop.Exists)
found |= movie.AddBackdropFromFile(newBackdrop.FullName);
}
}
return found;
}
示例2: getOldBackdrops
// check for backdrops in the backdrop folder loaded from previous installs
private bool getOldBackdrops(DBMovieInfo movie)
{
bool found = false;
string backdropFolderPath = MovingPicturesCore.Settings.BackdropFolder;
DirectoryInfo backdropFolder = new DirectoryInfo(backdropFolderPath);
string safeName = movie.Title.Replace(' ', '.').ToValidFilename();
Regex oldBackdropRegex = new Regex("^{?" + Regex.Escape(safeName) + "}? \\[-?\\d+\\]\\.(jpg|png)");
foreach (FileInfo currFile in backdropFolder.GetFiles()) {
if (oldBackdropRegex.IsMatch(currFile.Name)) {
found |= movie.AddBackdropFromFile(currFile.FullName);
}
}
return found;
}
示例3: GetBackdrop
public bool GetBackdrop(DBMovieInfo movie)
{
if (scraper == null)
return false;
Dictionary<string, string> paramList = new Dictionary<string, string>();
Dictionary<string, string> results;
// if we already have a backdrop move on for now
if (movie.BackdropFullPath.Trim().Length > 0)
return true;
// try to load the id for the movie for this script
DBSourceMovieInfo idObj = movie.GetSourceMovieInfo(ScriptID);
if (idObj != null && idObj.Identifier != null)
paramList["movie.site_id"] = idObj.Identifier;
// load params for scraper
foreach (DBField currField in DBField.GetFieldList(typeof(DBMovieInfo)))
if (currField.GetValue(movie) != null)
paramList["movie." + currField.FieldName] = currField.GetValue(movie).ToString().Trim();
//set higher level settings for script to use
paramList["settings.defaultuseragent"] = MovingPicturesCore.Settings.UserAgent;
paramList["settings.mepo_data"] = Config.GetFolder(Config.Dir.Config);
// run the scraper
results = scraper.Execute("get_backdrop", paramList);
if (results == null) {
logger.Error(Name + " scraper script failed to execute \"get_backdrop\" node.");
return false;
}
// Loop through all the results until a valid backdrop is found
int count = 0;
while (results.ContainsKey("backdrop[" + count + "].url") || results.ContainsKey("backdrop[" + count + "].file")) {
// attempt to load via a URL
if (results.ContainsKey("backdrop[" + count + "].url")) {
string backdropURL = results["backdrop[" + count + "].url"];
if (backdropURL.Trim().Length > 0)
if (movie.AddBackdropFromURL(backdropURL) == ImageLoadResults.SUCCESS)
return true;
}
// attempt to load via a file
if (results.ContainsKey("backdrop[" + count + "].file")) {
string backdropFile = results["backdrop[" + count + "].file"];
if (backdropFile.Trim().Length > 0)
if (movie.AddBackdropFromFile(backdropFile))
return true;
}
count++;
}
// no valid backdrop found
return false;
}