本文整理汇总了C#中MediaPortal.Plugins.MovingPictures.Database.DBMovieInfo类的典型用法代码示例。如果您正苦于以下问题:C# DBMovieInfo类的具体用法?C# DBMovieInfo怎么用?C# DBMovieInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DBMovieInfo类属于MediaPortal.Plugins.MovingPictures.Database命名空间,在下文中一共展示了DBMovieInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenamableFile
public RenamableFile(DBMovieInfo movie, DBLocalMedia localMedia)
{
_movie = movie;
_localMedia = localMedia;
_originalName = localMedia.FullPath;
_originalFile = localMedia.File;
}
示例2: Get
public static DBSourceMovieInfo Get(DBMovieInfo movie, DBSourceInfo source)
{
foreach (DBSourceMovieInfo currInfo in movie.SourceMovieInfo)
if (currInfo.Source == source)
return currInfo;
return null;
}
示例3: PlayMovie
/// <summary>
/// Play a movie with MovingPictures.
///
/// Taken from Trakt-for-MediaPortal:
/// https://github.com/Technicolour/Trakt-for-Mediaportal/blob/master/TraktPlugin/TraktHandlers/MovingPictures.cs
/// </summary>
/// <param name="movie">Movie to play</param>
/// <param name="resume">Ask to resume movie?</param>
public static void PlayMovie(DBMovieInfo movie, bool resume, int startPosition = 0)
{
if (movie == null) return;
// Play on a new thread
ThreadStart ts = delegate() { DoPlayMovie(movie, resume, startPosition); };
Thread playMovieAsync = new Thread(ts);
playMovieAsync.Start();
}
示例4: AddWatchedHistory
public static void AddWatchedHistory(DBMovieInfo movie, DBUser user)
{
DBWatchedHistory history = new DBWatchedHistory();
history.DateWatched = DateTime.Now;
history.Movie = movie;
history.User = user;
movie.WatchedHistory.Add(history);
history.Commit();
movie.Commit();
}
示例5: DetermineGroupName
private static string DetermineGroupName(DBMovieInfo movie)
{
switch (Browser.CurrentSortField) {
case SortingFields.Title:
// Either the first character of the title, or the word "Numeric"
// should we have a category for special characters like numeric has?
string groupName = "";
if (movie.SortBy.Trim().Length > 0)
groupName = movie.SortBy.Trim().Substring(0, 1).ToUpper();
// group all non-word characters together
if (!Regex.Match(groupName, @"\w").Success)
groupName = "#";
// numeric group
int iTemp;
if (int.TryParse(groupName, out iTemp))
groupName = "0-9";
return groupName;
case SortingFields.DateAdded:
return GetDateGroupName(movie.DateAdded.Date);
case SortingFields.ReleaseDate:
return Translation.GetByName("MonthName" + movie.ReleaseDate.Month.ToString()) + ", " + movie.ReleaseDate.Year.ToString();
case SortingFields.Year:
return movie.Year.ToString();
case SortingFields.Certification:
return movie.Certification.Trim().ToUpper();
case SortingFields.Language:
return movie.Language.Trim().ToUpper();
case SortingFields.Score:
return Math.Round(movie.Score).ToString();
case SortingFields.Runtime:
return "";
case SortingFields.FileSize:
string size = movie.LocalMedia[0].FileSize.ToFormattedByteString();
// split the string to get size and unit
string[] splits = size.Split(' ');
// round the size to the nearest unit
int roundedSize = (int)Math.Round(double.Parse(splits[0]), MidpointRounding.ToEven);
// group by rounded size
return roundedSize.ToString() + " " + splits[1];
case SortingFields.FilePath:
if (movie.LocalMedia.Count > 0)
return movie.LocalMedia[0].File.Directory.ToString();
else
return "";
default:
return "";
}
}
示例6: GetArtwork
public bool GetArtwork(DBMovieInfo movie)
{
string myVideoCoversFolder = Config.GetFolder(Config.Dir.Thumbs) + "\\Videos\\Title";
Regex cleaner = new Regex("[\\\\/:*?\"<>|]");
string cleanTitle = cleaner.Replace(movie.Title, "_");
string id = movie.GetSourceMovieInfo(SourceInfo).Identifier;
string filename = myVideoCoversFolder + "\\" + cleanTitle + "{" + id + "}L.jpg";
if (System.IO.File.Exists(filename))
return movie.AddCoverFromFile(filename);
return false;
}
示例7: DetermineGroupName
private static string DetermineGroupName(DBMovieInfo movie)
{
switch (Browser.CurrentSortField) {
case SortingFields.Title:
// Either the first character of the title, or the word "Numeric"
// should we have a category for special characters like numeric has?
string groupName = "";
if (movie.SortBy.Trim().Length > 0)
groupName = movie.SortBy.Trim().Substring(0, 1).ToUpper();
// group all non-word characters together
if (!Regex.Match(groupName, @"\w").Success)
groupName = "#";
// numeric group
int iTemp;
if (int.TryParse(groupName, out iTemp))
groupName = "0-9";
return groupName;
case SortingFields.DateAdded:
return GetDateGroupName(movie.DateAdded.Date);
case SortingFields.Year:
return movie.Year.ToString();
case SortingFields.Certification:
return movie.Certification.Trim().ToUpper();
case SortingFields.Language:
return movie.Language.Trim().ToUpper();
case SortingFields.Score:
return Math.Round(movie.Score).ToString();
case SortingFields.Runtime:
return "";
case SortingFields.FilePath:
if (movie.LocalMedia.Count > 0)
return movie.LocalMedia[0].File.Directory.ToString();
else
return "";
default:
return "";
}
}
示例8: GetRenameActionList
// Returns a list of files and directories ready to be renamed, based on this movie.
// To perform a rename on this list call list.RenameApprovedItems();
public List<Renamable> GetRenameActionList(DBMovieInfo movie)
{
List<Renamable> renamableList = new List<Renamable>();
// if this is a disk or a ripped disk, we dont want to rename any files
if (movie.LocalMedia[0].ImportPath.IsOpticalDrive ||
movie.LocalMedia[0].IsBluray ||
movie.LocalMedia[0].IsDVD ||
movie.LocalMedia[0].IsHDDVD) {
return renamableList;
}
foreach (DBLocalMedia currFile in movie.LocalMedia) {
string primaryExtension = Path.GetExtension(currFile.FullPath);
string path = Path.GetDirectoryName(currFile.FullPath);
string newFileName = GetNewFileName(currFile);
// generate primary renamable file for the current video file
if (MovingPicturesCore.Settings.RenameFiles) {
RenamableFile primaryRenamable = new RenamableFile(movie, currFile);
primaryRenamable.NewName = path + @"\" + newFileName + primaryExtension;
renamableList.Add(primaryRenamable);
}
// generate secondary renamable files for subtitles, etc
if (MovingPicturesCore.Settings.RenameSecondaryFiles) {
renamableList.AddRange(GetSecondaryFiles(currFile));
}
}
// generate a renamable object for the directory as needed
if (MovingPicturesCore.Settings.RenameFolders) {
RenamableDirectory renamableDir = GetDirectoryRenamable(movie);
if (renamableDir != null) renamableList.Add(renamableDir);
}
renamableList.UpdateFinalFilenames();
return renamableList;
}
示例9: FromUrl
public static Backdrop FromUrl(DBMovieInfo movie, string url, bool ignoreRestrictions, out ImageLoadResults status)
{
ImageSize minSize = null;
ImageSize maxSize = new ImageSize();
if (!ignoreRestrictions) {
minSize = new ImageSize();
minSize.Width = MovingPicturesCore.Settings.MinimumBackdropWidth;
minSize.Height = MovingPicturesCore.Settings.MinimumBackdropHeight;
}
maxSize.Width = MovingPicturesCore.Settings.MaximumBackdropWidth;
maxSize.Height = MovingPicturesCore.Settings.MaximumBackdropHeight;
bool redownload = MovingPicturesCore.Settings.RedownloadBackdrops;
Backdrop newBackdrop = new Backdrop();
newBackdrop.Filename = GenerateFilename(movie, url);
status = newBackdrop.FromUrl(url, ignoreRestrictions, minSize, maxSize, redownload);
switch (status) {
case ImageLoadResults.SUCCESS:
logger.Info("Added backdrop for \"{0}\" from: {1}", movie.Title, url);
break;
case ImageLoadResults.SUCCESS_REDUCED_SIZE:
logger.Info("Added resized backdrop for \"{0}\" from: {1}", movie.Title, url);
break;
case ImageLoadResults.FAILED_ALREADY_LOADED:
logger.Debug("Backdrop for \"{0}\" from the following URL is already loaded: {1}", movie.Title, url);
return null;
case ImageLoadResults.FAILED_TOO_SMALL:
logger.Debug("Downloaded backdrop for \"{0}\" failed minimum resolution requirements: {1}", movie.Title, url);
return null;
case ImageLoadResults.FAILED:
logger.Error("Failed downloading backdrop for \"{0}\": {1}", movie.Title, url);
return null;
}
return newBackdrop;
}
示例10: onMovieEnded
private void onMovieEnded(DBMovieInfo movie)
{
// update watched counter
updateMovieWatchedCounter(movie);
// clear resume state
clearMovieResumeState(movie);
// reset player
resetPlayer();
if (MovingPicturesCore.Settings.FollwitEnabled)
MovingPicturesCore.Follwit.CurrentlyWatching(movie, false);
// invoke event
if (MovieEnded != null)
MovieEnded(movie);
}
示例11: onMovieStopped
private void onMovieStopped(DBMovieInfo movie)
{
// reset player
resetPlayer();
if (MovingPicturesCore.Settings.FollwitEnabled)
MovingPicturesCore.Follwit.CurrentlyWatching(movie, false);
// invoke event
if (MovieStopped != null)
MovieStopped(movie);
}
示例12: getTmdbId
/// <summary>
/// returns the tmdb id for a movie if its exists
/// </summary>
private string getTmdbId(DBMovieInfo movie)
{
// get source info, maybe already have it from poster or movieinfo
var tmdbSource = DBSourceInfo.GetAll().Find(s => s.ToString() == "themoviedb.org");
if (tmdbSource == null)
return null;
string id = movie.GetSourceMovieInfo(tmdbSource).Identifier;
if (id == null || id.Trim() == string.Empty)
return null;
return id;
}
示例13: GetArtwork
public bool GetArtwork(DBMovieInfo movie)
{
if (movie == null)
return false;
// do we have an id?
string movieId = getMovieId(movie);
if (string.IsNullOrEmpty(movieId))
return false;
string url = apiMovieArtwork;
if (!string.IsNullOrEmpty(MovingPicturesCore.Settings.FanartTVClientKey))
url = url + "&client_key=" + MovingPicturesCore.Settings.FanartTVClientKey;
// try to get movie artwork
string response = getJson(string.Format(apiMovieArtwork, movieId));
if (response == null)
return false;
// de-serialize json response
var movieImages = response.FromJson<Artwork>();
if (movieImages == null)
return false;
// check if we have any posters
if (movieImages.movieposter == null || movieImages.movieposter.Count == 0)
return false;
// filter posters by language
var langPosters = movieImages.movieposter.Where(p => p.lang == MovingPicturesCore.Settings.DataProviderLanguageCode);
// if no localised posters available use all posters
if (langPosters.Count() == 0) {
langPosters = movieImages.movieposter;
}
// sort by highest rated / most popular
langPosters = langPosters.OrderByDescending(p => p.likes);
// grab coverart loading settings
int maxCovers = MovingPicturesCore.Settings.MaxCoversPerMovie;
int maxCoversInSession = MovingPicturesCore.Settings.MaxCoversPerSession;
int coversAdded = 0;
// download posters
foreach (var poster in langPosters) {
// if we have hit our limit quit
if (movie.AlternateCovers.Count >= maxCovers || coversAdded >= maxCoversInSession)
return true;
// get url for cover and load it via the movie object
string coverPath = poster.url;
if (coverPath.Trim() != string.Empty) {
if (movie.AddCoverFromURL(coverPath) == ImageLoadResults.SUCCESS)
coversAdded++;
}
}
if (coversAdded > 0) {
// Update source info
movie.GetSourceMovieInfo(SourceInfo).Identifier = movieId;
return true;
}
return false;
}
示例14: PromptUserToResume
private bool PromptUserToResume(DBMovieInfo movie)
{
if (movie.UserSettings == null || movie.UserSettings.Count == 0 || (movie.ActiveUserSettings.ResumePart < 2 && movie.ActiveUserSettings.ResumeTime <= 30))
return false;
logger.Debug("Resume Prompt: Movie='{0}', ResumePart={1}, ResumeTime={2}", movie.Title, movie.ActiveUserSettings.ResumePart, movie.ActiveUserSettings.ResumeTime);
// figure out the resume time to display to the user
int displayTime = movie.ActiveUserSettings.ResumeTime;
if (movie.LocalMedia.Count > 1) {
for (int i = 0; i < movie.ActiveUserSettings.ResumePart - 1; i++) {
if (movie.LocalMedia[i].Duration > 0)
displayTime += (movie.LocalMedia[i].Duration / 1000); // convert milliseconds to seconds
}
}
string sbody = movie.Title + "\n" + Translation.ResumeFrom + " " + Util.Utils.SecondsToHMSString(displayTime);
bool bResume = _gui.ShowCustomYesNo(Translation.ResumeFromLast, sbody, null, null, true);
if (bResume)
return true;
return false;
}
示例15: updateMovieResumeState
private void updateMovieResumeState(DBMovieInfo movie, int part, int timePlayed, byte[] resumeData, int titleBD)
{
if (movie.UserSettings.Count == 0)
return;
// get the user settings for the default profile (for now)
DBUserMovieSettings userSetting = movie.ActiveUserSettings;
if (timePlayed > 0 && g_Player.SetResumeBDTitleState >= 0) {
// set part and time data
userSetting.ResumePart = part;
userSetting.ResumeTime = timePlayed;
userSetting.ResumeData = new ByteArray(resumeData);
userSetting.ResumeTitleBD = titleBD;
logger.Debug("Updating movie resume state.");
}
else {
// clear the resume settings
userSetting.ResumePart = 0;
userSetting.ResumeTime = 0;
userSetting.ResumeData = null;
userSetting.ResumeTitleBD = 1000;
g_Player.SetResumeBDTitleState = userSetting.ResumeTitleBD;
logger.Debug("Clearing movie resume state.");
}
// save the changes to the user setting for this movie
userSetting.Commit();
}