Пример #1
0
	VkontakteruPlayer::VkontakteruPlayer (const QUrl& url,
		const QStringList& args, const QStringList& values)
	: Player (url, args, values)
	{
		Ui_.Quality_->hide ();
		Ui_.Related_->hide ();

		// http://'host'/assets/videos/'vtag+vkid'.vk.flv
		QString host = GetStringFromRX ("host=([0-9a-z\\.]+)", values[2]);
		QString vtag = GetStringFromRX ("vtag=([0-9a-f\\-]+)", values[2]);
		QString vkid = GetStringFromRX ("vkid=([0-9a-f]+)", values[2]);

		if (host.isEmpty () ||
					vtag.isEmpty () ||
					vkid.isEmpty ())
		{      
				qWarning () << Q_FUNC_INFO
					<< "one of required attrs is empty"
					<< host
					<< vtag
					<< vkid;
		} 
		else
		{
			QString source = "http://HOST/assets/videos/VTAGVKID.vk.flv";
			source.replace ("HOST", host);
			source.replace ("VTAG", vtag);
			source.replace ("VKID", vkid);
#ifdef QT_DEBUG
			qDebug () << "source" << source;
#endif
			SetVideoUrl (source);
		}
	}
Пример #2
0
	void VideoFindProxy::HandleVideoPage (const QString& contents)
	{
		// http://cs12739.vkontakte.ru/u16199765/video/1684dec3e6.240.mp4
		// -----------$host-----------/--$user--/video/---$vtag--.240.mp4
		QString host = GetStringFromRX (".*\"host\":\"([0-9a-z/\\:\\.\\\\]*)\".*", contents);
		QString user = GetStringFromRX (".*\"uid\":\"([0-9]*)\".*", contents);
		QString vtag = GetStringFromRX (".*\"vtag\":\"([0-9a-f\\-]*)\".*", contents);
		// Not needed anymore, but let's have it here just in case.
		// QString vkid = GetStringFromRX (".*\"vkid\":\"([0-9a-f]*)\".*", contents);

		host.replace ("\\/", "/");
		if (host.endsWith ('/'))
			host.chop (1);

		if (host.isEmpty () ||
				vtag.isEmpty () ||
				user.isEmpty ())
		{
			qWarning () << Q_FUNC_INFO
				<< "one of required attrs is empty"
				<< host
				<< vtag
				<< user
				<< "for"
				<< contents;
			return;
		}

		QString source = QString ("%1/u%2/video/%3.240.mp4")
				.arg (host)
				.arg (user)
				.arg (vtag);

		qDebug () << Q_FUNC_INFO
				<< source;

		LeechCraft::TaskParameter hd = OnlyHandle;
		switch (Type_)
		{
			case PTInvalid:
				qWarning () << Q_FUNC_INFO
					<< "invalid Type_, assuming both Download and Handle";
				break;
			case PTHandle:
				hd = OnlyHandle;
				break;
			case PTDownload:
				hd = OnlyDownload;
				break;
		}

		EmitWith (hd, QUrl (source));
	}