diff --git a/mythtv/libs/libmythmetadata/metadatacommon.cpp b/mythtv/libs/libmythmetadata/metadatacommon.cpp
index d28d54e..14f1a9e 100644
a
|
b
|
MetadataLookup::MetadataLookup( |
219 | 219 | m_artwork(artwork), |
220 | 220 | m_downloads(downloads) |
221 | 221 | { |
| 222 | QString manRecSuffix = QString(" (%1)").arg(QObject::tr("Manual Record")); |
| 223 | m_base_title = title; |
| 224 | m_base_title.replace(manRecSuffix,""); |
222 | 225 | } |
223 | 226 | |
224 | 227 | // ProgramInfo-style constructor |
… |
… |
MetadataLookup::MetadataLookup( |
312 | 315 | m_popularity = 0; |
313 | 316 | m_budget = 0; |
314 | 317 | m_revenue = 0; |
| 318 | QString manRecSuffix = QString(" (%1)").arg(QObject::tr("Manual Record")); |
| 319 | m_base_title = title; |
| 320 | m_base_title.replace(manRecSuffix,""); |
315 | 321 | } |
316 | 322 | |
317 | 323 | // XBMC NFO-style constructor |
… |
… |
MetadataLookup::MetadataLookup( |
388 | 394 | m_artwork(artwork), |
389 | 395 | m_downloads(downloads) |
390 | 396 | { |
| 397 | QString manRecSuffix = QString(" (%1)").arg(QObject::tr("Manual Record")); |
| 398 | m_base_title = title; |
| 399 | m_base_title.replace(manRecSuffix,""); |
391 | 400 | } |
392 | 401 | |
393 | 402 | MetadataLookup::~MetadataLookup() |
diff --git a/mythtv/libs/libmythmetadata/metadatadownload.cpp b/mythtv/libs/libmythmetadata/metadatadownload.cpp
index bf5d4fb..5c6194b 100644
a
|
b
|
MetadataLookup* MetadataDownload::findBestMatch(MetadataLookupList list, |
204 | 204 | { |
205 | 205 | QStringList titles; |
206 | 206 | MetadataLookup *ret = NULL; |
| 207 | QDate exactTitleDate; |
207 | 208 | |
208 | 209 | // Build a list of all the titles |
209 | 210 | int exactMatches = 0; |
210 | 211 | for (MetadataLookupList::const_iterator i = list.begin(); |
211 | 212 | i != list.end(); ++i) |
212 | 213 | { |
213 | | QString title = (*i)->GetBaseTitle(); |
214 | | if (title == originaltitle) |
| 214 | QString title = (*i)->GetTitle(); |
| 215 | LOG(VB_GENERAL, LOG_INFO, QString("Comparing metadata title '%1' to recording title '%2'") |
| 216 | .arg(title) |
| 217 | .arg(originaltitle)); |
| 218 | if (QString::compare(title, originaltitle, Qt::CaseInsensitive) == 0) |
215 | 219 | { |
216 | | ret = (*i); |
| 220 | // We have an exact match on the title (ignoring case). After |
| 221 | // the first exact match, prefer any more recently released one. |
| 222 | if ((ret == NULL) || ((*i)->GetReleaseDate() > exactTitleDate)) |
| 223 | { |
| 224 | exactTitleDate = (*i)->GetReleaseDate(); |
| 225 | ret = (*i); |
| 226 | } |
217 | 227 | exactMatches++; |
218 | 228 | } |
219 | 229 | |
… |
… |
MetadataLookup* MetadataDownload::findBestMatch(MetadataLookupList list, |
226 | 236 | { |
227 | 237 | if (exactMatches == 1) |
228 | 238 | { |
229 | | LOG(VB_GENERAL, LOG_INFO, QString("Single Exact Title Match For %1") |
| 239 | LOG(VB_GENERAL, LOG_INFO, QString("Single exact title match for '%1'") |
230 | 240 | .arg(originaltitle)); |
231 | | return ret; |
232 | 241 | } |
233 | 242 | else |
234 | 243 | { |
235 | | LOG(VB_GENERAL, LOG_ERR, |
236 | | QString("Multiple exact title matches found for %1. " |
237 | | "Need to match on other criteria.") |
238 | | .arg(originaltitle)); |
239 | | return NULL; |
| 244 | LOG(VB_GENERAL, LOG_INFO, |
| 245 | QString("Multiple exact title matches found for '%1'. " |
| 246 | "Selecting most recent [%2]") |
| 247 | .arg(originaltitle) |
| 248 | .arg(exactTitleDate.toString())); |
240 | 249 | } |
| 250 | return ret; |
241 | 251 | } |
242 | 252 | |
243 | 253 | // Apply Levenshtein distance algorithm to determine closest match |
… |
… |
MetadataLookup* MetadataDownload::findBestMatch(MetadataLookupList list, |
260 | 270 | MetadataLookupList::const_iterator i = list.begin(); |
261 | 271 | for (; i != list.end(); ++i) |
262 | 272 | { |
263 | | if ((*i)->GetBaseTitle() == bestTitle) |
| 273 | if ((*i)->GetTitle() == bestTitle) |
264 | 274 | { |
265 | 275 | ret = (*i); |
266 | 276 | break; |
diff --git a/mythtv/programs/mythmetadatalookup/lookup.cpp b/mythtv/programs/mythmetadatalookup/lookup.cpp
index 6de23a1..eb3c2ab 100644
a
|
b
|
void LookerUpper::customEvent(QEvent *levent) |
246 | 246 | if (list.count() > 1) |
247 | 247 | { |
248 | 248 | int yearindex = -1; |
| 249 | MetadataLookup *exactTitleMeta = NULL; |
| 250 | QDate exactTitleDate; |
249 | 251 | |
250 | 252 | for (int p = 0; p != list.size(); ++p) |
251 | 253 | { |
252 | 254 | ProgramInfo *pginfo = list[p]->GetData().value<ProgramInfo *>(); |
253 | 255 | |
| 256 | if (pginfo && (QString::compare(pginfo->GetTitle(), list[p]->GetBaseTitle(), Qt::CaseInsensitive)) == 0) |
| 257 | { |
| 258 | // We have an exact match on the title (ignoring case) |
| 259 | if ((exactTitleMeta == NULL) || |
| 260 | (list[p]->GetReleaseDate() > exactTitleDate)) |
| 261 | { |
| 262 | // remember the most recently released exact match |
| 263 | exactTitleDate = list[p]->GetReleaseDate(); |
| 264 | exactTitleMeta = list[p]; |
| 265 | } |
| 266 | } |
| 267 | |
254 | 268 | if (pginfo && !pginfo->GetSeriesID().isEmpty() && |
255 | 269 | pginfo->GetSeriesID() == (list[p])->GetTMSref()) |
256 | 270 | { |
… |
… |
void LookerUpper::customEvent(QEvent *levent) |
291 | 305 | return; |
292 | 306 | } |
293 | 307 | |
| 308 | if (exactTitleMeta != NULL) |
| 309 | { |
| 310 | LOG(VB_GENERAL, LOG_INFO, QString("Most recent exact match released %1").arg(exactTitleDate.toString())); |
| 311 | MetadataLookup *lookup = exactTitleMeta; |
| 312 | ProgramInfo *pginfo = exactTitleMeta->GetData().value<ProgramInfo *>(); |
| 313 | if (lookup->GetSubtype() != kProbableGenericTelevision) |
| 314 | pginfo->SaveSeasonEpisode(lookup->GetSeason(), lookup->GetEpisode()); |
| 315 | pginfo->SaveInetRef(lookup->GetInetref()); |
| 316 | m_busyRecList.removeAll(pginfo); |
| 317 | return; |
| 318 | } |
| 319 | |
294 | 320 | LOG(VB_GENERAL, LOG_INFO, "Unable to match this title, too many possible matches. " |
295 | 321 | "You may wish to manually set the season, episode, and " |
296 | 322 | "inetref in the 'Watch Recordings' screen."); |