Guest User

Untitled

a guest
May 19th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.20 KB | None | 0 0
  1. From 45d51a2b928ee76de9f30a3aecce81effc3b8c5f Mon Sep 17 00:00:00 2001
  2. From: montellese <montellese@xbmc.org>
  3. Date: Sun, 8 Jan 2012 13:04:20 +0100
  4. Subject: [PATCH 4/4] fix invalid details in Player announcements by doing a
  5.  manual database lookup by path
  6.  
  7. ---
  8. xbmc/interfaces/AnnouncementManager.cpp |   46 +++++++++++++++++++++++++++++-
  9.  1 files changed, 44 insertions(+), 2 deletions(-)
  10.  
  11. diff --git a/xbmc/interfaces/AnnouncementManager.cpp b/xbmc/interfaces/AnnouncementManager.cpp
  12. index 3403ccd..166ad10 100644
  13. --- a/xbmc/interfaces/AnnouncementManager.cpp
  14. +++ b/xbmc/interfaces/AnnouncementManager.cpp
  15. @@ -26,8 +26,11 @@
  16.  #include "utils/Variant.h"
  17.  #include "FileItem.h"
  18.  #include "music/tags/MusicInfoTag.h"
  19. +#include "music/MusicDatabase.h"
  20.  #include "video/VideoDatabase.h"
  21.  
  22. +#define LOOKUP_PROPERTY "database-lookup"
  23. +
  24.  using namespace std;
  25.  using namespace ANNOUNCEMENT;
  26.  
  27. @@ -82,12 +85,29 @@ void CAnnouncementManager::Announce(EAnnouncementFlag flag, const char *sender,
  28.  
  29.    if (item->HasVideoInfoTag())
  30.    {
  31. -    CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);
  32. -
  33.      id = item->GetVideoInfoTag()->m_iDbId;
  34.  
  35. +    // TODO: Can be removed once this is properly handled when starting playback of a file
  36. +    if (id <= 0 && !item->GetPath().empty() &&
  37. +       (!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
  38. +    {
  39. +      CVideoDatabase videodatabase;
  40. +      if (videodatabase.Open())
  41. +      {
  42. +        if (videodatabase.LoadVideoInfo(item->GetPath(), *item->GetVideoInfoTag()))
  43. +          id = item->GetVideoInfoTag()->m_iDbId;
  44. +
  45. +        videodatabase.Close();
  46. +      }
  47. +    }
  48. +
  49. +    CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type);
  50. +
  51.      if (id <= 0)
  52.      {
  53. +      // TODO: Can be removed once this is properly handled when starting playback of a file
  54. +      item->SetProperty(LOOKUP_PROPERTY, false);
  55. +
  56.        object["title"] = item->GetVideoInfoTag()->m_strTitle;
  57.  
  58.        switch (item->GetVideoContentType())
  59. @@ -118,8 +138,30 @@ void CAnnouncementManager::Announce(EAnnouncementFlag flag, const char *sender,
  60.      id = item->GetMusicInfoTag()->GetDatabaseId();
  61.      type = "song";
  62.  
  63. +    // TODO: Can be removed once this is properly handled when starting playback of a file
  64. +    if (id <= 0 && !item->GetPath().empty() &&
  65. +       (!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean()))
  66. +    {
  67. +      CMusicDatabase musicdatabase;
  68. +      if (musicdatabase.Open())
  69. +      {
  70. +        CSong song;
  71. +        if (musicdatabase.GetSongByFileName(item->GetPath(), song))
  72. +        {
  73. +          item->GetMusicInfoTag()->SetSong(song);
  74. +          item->SetMusicThumb();
  75. +          id = item->GetMusicInfoTag()->GetDatabaseId();
  76. +        }
  77. +
  78. +        musicdatabase.Close();
  79. +      }
  80. +    }
  81. +
  82.      if (id <= 0)
  83.      {
  84. +      // TODO: Can be removed once this is properly handled when starting playback of a file
  85. +      item->SetProperty(LOOKUP_PROPERTY, false);
  86. +
  87.        object["title"] = item->GetMusicInfoTag()->GetTitle();
  88.  
  89.        if (item->GetMusicInfoTag()->GetTrackNumber() > 0)
  90. --
  91. 1.7.7.msysgit.0
Add Comment
Please, Sign In to add comment