Changeset 170 for smplayer/trunk/src/findsubtitles/osclient.cpp
- Timestamp:
- Oct 9, 2014, 2:54:21 PM (11 years ago)
- Location:
- smplayer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
smplayer/trunk
- Property svn:mergeinfo changed
/smplayer/vendor/current merged: 168
- Property svn:mergeinfo changed
-
smplayer/trunk/src/findsubtitles/osclient.cpp
r165 r170 20 20 #include "version.h" 21 21 22 OSClient::OSClient(QObject* parent) : QObject(parent), logged_in(false), search_size(0) { 22 OSClient::OSClient(QObject* parent) : 23 QObject(parent) 24 , logged_in(false) 25 , search_size(0) 26 #ifdef OS_SEARCH_WORKAROUND 27 , best_search_count(0) 28 #endif 29 { 23 30 rpc = new MaiaXmlRpcClient(QUrl("http://api.opensubtitles.org/xml-rpc"), this); 24 31 } … … 66 73 } 67 74 75 #ifdef OS_SEARCH_WORKAROUND 68 76 void OSClient::doSearch() { 77 best_search_count = -1; 78 for (int n = 1; n < 8; n++) doSearch(n); 79 } 80 81 void OSClient::doSearch(int nqueries) { 82 #else 83 void OSClient::doSearch() { 84 #endif 69 85 qDebug("OSClient::doSearch"); 70 86 … … 74 90 m["moviebytesize"] = QString::number(search_size); 75 91 76 // For some reason it seems opensubtitles fails77 // sometimes if there's only one item in the list.78 // So as workaround, the item is appended twice.79 80 // Update: and the opposite, sometimes it doesn't return any81 // result with 2 items but it does with 1.82 // Workaround: use 3 items... Seems to work in all cases.83 92 QVariantList list; 93 #ifdef OS_SEARCH_WORKAROUND 94 // Sometimes opensubtitles return 0 subtitles 95 // A workaround seems to add the query several times 96 qDebug("OSClient::doSearch: nqueries: %d", nqueries); 97 for (int count = 0; count < nqueries; count++) list.append(m); 98 //qDebug("OSClient::doSearch: list count: %d", list.count()); 99 #else 84 100 list.append(m); 85 list.append(m); 86 list.append(m); 87 list.append(m); 88 //list.append(m); 89 list.append(m); // Adding more, sometimes it keeps failing... 101 #endif 90 102 91 103 QVariantList args; … … 148 160 QVariantList data = m["data"].toList(); 149 161 qDebug("OSClient::responseSearch: data count: %d", data.count()); 162 163 #ifdef OS_SEARCH_WORKAROUND 164 if (best_search_count >= data.count()) { 165 qDebug("OSClient::responseSearch: we already have a better search (%d). Ignoring this one.", best_search_count); 166 return; 167 } 168 best_search_count = data.count(); 169 #endif 150 170 151 171 for (int n = 0; n < data.count(); n++) {
Note:
See TracChangeset
for help on using the changeset viewer.