Advertisement
Guest User

Untitled

a guest
Jul 16th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. /**
  2. * handleTelevision
  3. * attempt to find television data via the following (in order)
  4. * 1- By inetref with subtitle
  5. * 2- By inetref with season and episode
  6. * 3- By inetref with season
  7. * 4- By inetref
  8. * 5- By title and subtitle
  9. * 6- By title
  10. */
  11. MetadataLookupList MetadataDownload::handleTelevision(MetadataLookup *lookup)
  12. {
  13. MetadataLookupList list;
  14. MetaGrabberScript grabber =
  15. MetaGrabberScript::GetGrabber(kGrabberTelevision, lookup);
  16.  
  17. // initial search mode
  18. if (!lookup->GetInetref().isEmpty() && lookup->GetInetref() != "00000000" &&
  19. (lookup->GetStep() == kLookupSearch || lookup->GetStep() == kLookupData))
  20. {
  21. // with inetref
  22. lookup->SetStep(kLookupData);
  23. if (!lookup->GetSubtitle().isEmpty())
  24. {
  25. list = grabber.SearchSubtitle(lookup->GetInetref(),
  26. lookup->GetTitle() /* unused */,
  27. lookup->GetSubtitle(), lookup, false);
  28. }
  29.  
  30. if (list.isEmpty() && lookup->GetSeason() && lookup->GetEpisode())
  31. {
  32. list = grabber.LookupData(lookup->GetInetref(), lookup->GetSeason(),
  33. lookup->GetEpisode(), lookup);
  34. }
  35.  
  36. if (list.isEmpty() && lookup->GetSeasons())
  37. {
  38. list = grabber.LookupData(lookup->GetInetref(),
  39. lookup->GetSeason(),
  40. lookup);
  41. }
  42. if (list.isEmpty() && !lookup->GetCollectionref().isEmpty())
  43. {
  44. list = grabber.LookupCollection(lookup->GetCollectionref(), lookup);
  45. }
  46. }
  47. else if (lookup->GetStep() == kLookupSearch)
  48. {
  49. if (lookup->GetTitle().isEmpty())
  50. {
  51. // no point searching on nothing...
  52. return list;
  53. }
  54. if (!lookup->GetSubtitle().isEmpty())
  55. {
  56. list = grabber.SearchSubtitle(lookup->GetTitle(),
  57. lookup->GetSubtitle(), lookup, false);
  58. }
  59. if (list.isEmpty())
  60. {
  61. list = grabber.Search(lookup->GetTitle(), lookup);
  62. }
  63. }
  64. else if (lookup->GetStep() == kLookupCollection)
  65. {
  66. list = grabber.LookupCollection(lookup->GetCollectionref(), lookup);
  67. }
  68.  
  69. // Collection Fallback
  70. // If the lookup allows generic metadata, and the specific
  71. // season and episode are not available, try for series metadata.
  72. if (list.isEmpty() && !lookup->GetCollectionref().isEmpty() &&
  73. lookup->GetAllowGeneric() &&
  74. lookup->GetStep() == kLookupData)
  75. {
  76. lookup->SetStep(kLookupCollection);
  77. list = grabber.LookupCollection(lookup->GetCollectionref(), lookup);
  78. }
  79.  
  80. return list;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement