X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fdownloaditem.cpp;h=58714e026143ebc5a53b2104ee35248dbd18bbe2;hb=85ceb092e55da1ca4bb95a535303a2c50f2b9644;hp=9b7982163cf5ed2c3d85f31bbc675fff1bc779ee;hpb=994e6e5e95196b0e36c680b1fd496f12d71739c9;p=minitube diff --git a/src/downloaditem.cpp b/src/downloaditem.cpp index 9b79821..58714e0 100644 --- a/src/downloaditem.cpp +++ b/src/downloaditem.cpp @@ -19,7 +19,8 @@ along with Minitube. If not, see . $END_LICENSE */ #include "downloaditem.h" -#include "networkaccess.h" +#include "http.h" +#include "httputils.h" #include "video.h" #include @@ -29,10 +30,6 @@ $END_LICENSE */ #include "macutils.h" #endif -namespace The { - NetworkAccess* http(); -} - DownloadItem::DownloadItem(Video *video, QUrl url, QString filename, QObject *parent) : QObject(parent) , m_bytesReceived(0) @@ -126,10 +123,11 @@ void DownloadItem::seekTo(qint64 offset, bool sendStatusChanges) { void DownloadItem::start() { // qDebug() << "Starting download at" << m_offset; - if (m_offset > 0) - m_reply = The::http()->request(m_url, QNetworkAccessManager::GetOperation, QByteArray(), m_offset); - else - m_reply = The::http()->request(m_url); + HttpRequest req; + req.url = m_url; + if (m_offset > 0) req.offset = m_offset; + m_reply = HttpUtils::yt().networkReply(req); + init(); } @@ -282,8 +280,8 @@ void DownloadItem::downloadProgress(qint64 bytesReceived, qint64 bytesTotal) { if (bufferSize > bytesTotal) bufferSize = bytesTotal; // qDebug() << bytesReceived << bytesTotal << neededBytes << bufferSize << m_downloadTime.elapsed(); if (bytesReceived > bufferSize - && bytesReceived > neededBytes - && m_downloadTime.elapsed() > 2000) { + && bytesReceived > neededBytes + && m_downloadTime.elapsed() > 2000) { emit bufferProgress(100); m_status = Downloading; emit statusChanged(); @@ -437,7 +435,7 @@ QString DownloadItem::formattedTime(double timeRemaining, bool remaining) { } timeRemaining = floor(timeRemaining); QString msg = remaining ? tr("%4 %5 remaining") : "%4 %5"; - return msg + return msg .arg(timeRemaining) .arg(timeRemainingString); }