/
video_tudou.cpp
114 lines (102 loc) · 3.48 KB
/
video_tudou.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
ClipGrab³
Copyright (C) Philipp Schmieder
http://clipgrab.de
feedback [at] clipgrab [dot] de
This file is part of ClipGrab.
ClipGrab is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ClipGrab is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ClipGrab. If not, see <http://www.gnu.org/licenses/>.
*/
#include "video_tudou.h"
video_tudou::video_tudou()
{
this->_name = "Tudou";
this->_supportsTitle = true;
this->_supportsDescription = false;
this->_supportsThumbnail = false;
this->_supportsSearch = false;
this->_icon = 0;
this->_urlRegExp << QRegExp("http://.*tudou\\.com/programs/view/.*", Qt::CaseInsensitive);
_treeItem = NULL;
}
video* video_tudou::createNewInstance()
{
return new video_tudou();
}
void video_tudou::parseVideo(QString xml)
{
switch (this->_step)
{
case 1:
//
// Retrieving the video id
//
{
QRegExp expression;
QString iid;
expression = QRegExp("var iid = ([0-9]+)");
expression.indexIn(xml);
if (expression.indexIn(xml) !=-1)
{
iid = expression.cap(1);
tempFile = new QTemporaryFile(QDir::tempPath() + "/clipgrab-info--XXXXXX");
_finished = false;
if (this->_url.isValid())
{
_step = 2;
_redirectLevel = 0;
QNetworkRequest request;
request.setUrl(QUrl("http://v2.tudou.com/v2/cdn?id="+iid));
_currentNetworkReply = this->_networkAccessManager->get(request);
this->_redirectLevel = 0;
}
}
else
{
emit error("Could not retrieve video iid.", this);
}
break;
}
case 2:
{
QRegExp expression;
expression = QRegExp("ti?tl?e?=\"(.*)\"");
expression.setMinimal(true);
expression.indexIn(xml);
qDebug() << xml;
if (expression.indexIn(xml) !=-1)
{
_title = expression.cap(1);
qDebug() << _title;
expression = QRegExp("<f.*>(.*)</f>");
expression.setMinimal(true);
if (expression.indexIn(xml) !=-1)
{
videoQuality newQuality;
newQuality.quality = tr("normal");
newQuality.videoUrl = expression.cap(1).replace("&", "&");
newQuality.containerName = ".flv";
_supportedQualities.append(newQuality);
qDebug() << "------"+newQuality.videoUrl+"------";
emit analysingFinished();
}
else
{
emit error("Could not retrieve video url");
}
}
else
{
emit error("Could not retrieve video title");
}
}
}
}