diff --git a/src/findsubtitles/findsubtitleswindow.cpp b/src/findsubtitles/findsubtitleswindow.cpp index 6d0282cdd..d9dda3081 100644 --- a/src/findsubtitles/findsubtitleswindow.cpp +++ b/src/findsubtitles/findsubtitleswindow.cpp @@ -413,6 +413,9 @@ void FindSubtitlesWindow::showDownloadFailed() { void FindSubtitlesWindow::showErrorOS(int, const QString & error) { status->setText(error); + if (error.contains("299:")) { + status->setText(tr("Error: daily quota exceeded")); + } } void FindSubtitlesWindow::updateDataReadProgress(int done, int total) { @@ -495,16 +498,15 @@ void FindSubtitlesWindow::itemActivated(const QModelIndex & index ) { QString file_id = item->data(DATA_FILE_ID).toString(); qDebug() << "FindSubtitlesWindow::itemActivated: file_id:" << file_id; + int remaining_downloads; if (download_link.isEmpty()) { - download_link = osclient->getDownloadLink(file_id); + download_link = osclient->getDownloadLink(file_id, &remaining_downloads); item->setData(download_link); } qDebug() << "FindSubtitlesWindow::itemActivated: download link:" << download_link; if (download_link.isEmpty()) { // Failed to get the download link - QMessageBox::warning(this, tr("Error"), - tr("Failed to get the URL of the subtitle file.\nCheck your login credentials.")); return; } @@ -514,6 +516,7 @@ void FindSubtitlesWindow::itemActivated(const QModelIndex & index ) { #else QDesktopServices::openUrl( QUrl(download_link) ); #endif + status->setText(tr("Remaining downloads: %1").arg(remaining_downloads)); } void FindSubtitlesWindow::download() { @@ -531,12 +534,17 @@ void FindSubtitlesWindow::copyLink() { QString download_link = item->data().toString(); QString file_id = item->data(DATA_FILE_ID).toString(); qDebug() << "FindSubtitlesWindow::copyLink: file_id:" << file_id; + + int remaining_downloads; if (download_link.isEmpty()) { - download_link = osclient->getDownloadLink(file_id); + download_link = osclient->getDownloadLink(file_id, &remaining_downloads); item->setData(download_link); } qDebug() << "FindSubtitlesWindow::copyLink: link:" << download_link; - qApp->clipboard()->setText(download_link); + if (!download_link.isEmpty()) { + qApp->clipboard()->setText(download_link); + status->setText(tr("Remaining downloads: %1").arg(remaining_downloads)); + } } } diff --git a/src/findsubtitles/osclient.cpp b/src/findsubtitles/osclient.cpp index 704dd8084..d056914ea 100644 --- a/src/findsubtitles/osclient.cpp +++ b/src/findsubtitles/osclient.cpp @@ -185,7 +185,7 @@ void OSClient::search(const QString & hash, qint64 file_size, QString search_ter emit searchFinished(); } -QString OSClient::getDownloadLink(const QString & file_id) { +QString OSClient::getDownloadLink(const QString & file_id, int * remaining_downloads) { qDebug() << "OSClient::getDownloadLink:" << file_id; // Try to login @@ -224,6 +224,10 @@ QString OSClient::getDownloadLink(const QString & file_id) { QVariantMap map = result[0]; if (map.contains("link")) { link = map["link"].toString(); + qDebug() << "OSClient::getDownloadLink: remaining:" << map["remaining"].toInt(); + if (remaining_downloads) { + *remaining_downloads = map["remaining"].toInt(); + } } } diff --git a/src/findsubtitles/osclient.h b/src/findsubtitles/osclient.h index 80f91851b..bd4f5d262 100644 --- a/src/findsubtitles/osclient.h +++ b/src/findsubtitles/osclient.h @@ -54,7 +54,7 @@ class OSClient : public QObject { void setPassword(QString password) { os_password = password; }; QString password() { return os_password; }; - QString getDownloadLink(const QString & file_id); + QString getDownloadLink(const QString & file_id, int * remaining_downloads = 0); public slots: void search(const QString & hash, qint64 file_size, QString search_term = QString(), QString languages = QString()); diff --git a/src/findsubtitles/qrestapi/qRestAPI.cpp b/src/findsubtitles/qrestapi/qRestAPI.cpp index 28ef798d0..201b03ebf 100644 --- a/src/findsubtitles/qrestapi/qRestAPI.cpp +++ b/src/findsubtitles/qrestapi/qRestAPI.cpp @@ -261,6 +261,7 @@ void qRestAPIPrivate::processReply(QNetworkReply* reply) QString::number(static_cast(reply->error())) + ": " + reply->errorString(), errorCode); + qDebug() << "Error response:" << reply->readAll(); } else {