ensure buffer seek head is 0 before calling evalVideoInformation()

This commit is contained in:
Martchus 2015-10-14 23:18:41 +02:00
parent fd6afe426d
commit db7c8c32f6
6 changed files with 3 additions and 10 deletions

View File

@ -35,7 +35,6 @@ QString BitshareDownload::typeName() const
void BitshareDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
{
videoInfoBuffer->seek(0);
QString videoInfo(videoInfoBuffer->readAll());
QString title;
if(substring(videoInfo, title, 0, QStringLiteral("<title>Streaming "), QStringLiteral(" ")) > 0 && !title.isEmpty()) {

View File

@ -181,7 +181,6 @@ void GroovesharkDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuf
{
QString code;
if(videoInfoBuffer) { // the buffer might be zero!
videoInfoBuffer->seek(0);
code.append(videoInfoBuffer->readAll());
}
switch(m_currentStep) {

View File

@ -82,6 +82,7 @@ void HttpDownloadWithInfoRequst::infoRequestChangedStatus(Download *download)
if(!m_infoBuffer) {
reportInitiated(false, tr("The initialization data buffer hasn't been initialized."));
} else {
m_infoBuffer->seek(0);
evalVideoInformation(download, m_infoBuffer.get());
m_infoDownload.reset();
}

View File

@ -57,7 +57,6 @@ QString SockshareDownload::typeName() const
void SockshareDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
{
videoInfoBuffer->seek(0);
QString videoInfo(videoInfoBuffer->readAll());
int pos;
QString str;

View File

@ -104,7 +104,6 @@ void SpotifyDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
if(m_currentRequest == SpotifyRequestType::Invalid)
reportInitiated(false, tr("Interal error (current request type not set)."));
else {
videoInfoBuffer->seek(0);
switch(m_currentRequest) {
case SpotifyRequestType::GetAuthenticationData: {
QString responseData(videoInfoBuffer->readAll());

View File

@ -64,7 +64,6 @@ void YoutubeDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
}
m_itagInfo = loadJsonObjectFromResource(path);
}
videoInfoBuffer->seek(0);
QString videoInfo(videoInfoBuffer->readAll());
QStringList completeFields = videoInfo.split(QChar('&'), QString::SkipEmptyParts, Qt::CaseSensitive);
foreach(QString completeField, completeFields) {
@ -100,10 +99,7 @@ void YoutubeDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
QStringList sections = fmtField.split(QChar(','), QString::SkipEmptyParts, Qt::CaseSensitive);
foreach(QString section, sections) {
QStringList fmtParts = section.split(QChar('&'), QString::SkipEmptyParts, Qt::CaseSensitive);
QString itag;
QString urlPart1;
QString urlPart2;
QString name;
QString itag, urlPart1, urlPart2, name;
QJsonObject itagObj;
foreach(QString fmtPart, fmtParts) {
QStringList fmtSubParts = fmtPart.split(QChar('='), QString::SkipEmptyParts, Qt::CaseSensitive);
@ -150,7 +146,7 @@ void YoutubeDownload::evalVideoInformation(Download *, QBuffer *videoInfoBuffer)
}
}
}
if(availableOptionCount() > 0) {
if(availableOptionCount()) {
reportInitiated(true);
} else {
reportInitiated(false, tr("Couldn't pharse the video info. The status of the video info is ok, but it seems like YouTube changed something in their API."));