Example #1
0
//static
std::string LLLogChat::makeLogFileName(std::string filename)
{
	filename = cleanFileName(filename);
	filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename);
	filename += ".txt";
	return filename;
}
Example #2
0
int YoutubeDL::download(const QString URL, QString destination, QString fileName, QStringList params, bool autoName)
{
	if ( ! isYoutubeDLappInstalled())
		return EnumYoutubeDL::YOUTUBE_DL_APP_MISSING;

	// clean destination dir
	destination = QDir::cleanPath(destination);

#ifdef Q_OS_WIN32
	// fix Qt4.4.0 bug in windows
	if (destination.indexOf(":/") == -1)
		destination.replace(":", ":/");
#endif

	// check if is already downloading another file
	if (isDownloading())
		return EnumHTTP::ALREADY_DOWNLOADING;

	// create the destination path, if it don't exists
	if ( ! QDir(destination).exists())
		if ( ! QDir(destination).mkpath(destination))
			return EnumHTTP::UNABLE_CREATE_DIR;

	// set a default name (only if it is empty)
	if (fileName.isEmpty())
		fileName = "download.file";

	fileName = QFileInfo(fileName).fileName();

	// set destination file name
	fileName = cleanFileName(fileName);

	// get an unique file name for this download
	if (autoName)
		fileName = uniqueFileName(destination + "/" + fileName);
	else
		fileName = destination + "/" + fileName;

	// set file info
	destinationFile = QFileInfo(fileName);

	// set as downloading
	resuming = false;

	// build the command line
	QStringList commandLine = QStringList() << "-o" << fileName << URL;
	foreach (QString value, params)
	{
		commandLine << value.split("=", QString::SkipEmptyParts);
	}
void VideoInformation::run()
{
	videoItem->lock(this);

	VideoInformationPlugin *service = getPluginByHost(QUrl(videoItem->getURL()));

	if (service != NULL)
	{
		if (isBlockedHost(videoItem->getURL()))
			videoItem->setAsBlocked(this);
		else
		{
			videoItem->setAsGettingURL(this);

			// if this item was market as "need update the url" then change the status to "updating url..."
			bool urlWasUpdated = videoItem->needUpdateUrl();
			if (urlWasUpdated) videoItem->setAsUpdatingURL();

			emit informationStarted(videoItem);

			VideoDefinition info = service->getVideoInformation(videoItem->getURL());

			// canceled?
			if (videoItem == NULL) return;

			if (info.needLogin)
			{
				videoItem->setAsNeedLogin(this);
				videoItem->removeUpdatingURLStatus();
			}
			else // ok, assign information and prepare the item to be downloaded
			{
				videoItem->setVideoInformation(info, this);
				if (!urlWasUpdated) videoItem->setVideoFile(cleanFileName(info.title + info.extension), this);
				videoItem->setAsGettedURL(this);
			}
		}
	}
	else
		videoItem->setAsError(this);

	videoItem->unlock(this);
	emit informationFinished(videoItem);
}
//static
std::string LLLogChat::makeLogFileName(std::string filename)
{
	if (gSavedPerAccountSettings.getBOOL("LogFileNamewithDate"))
	{
		time_t now; 
		time(&now); 
		char dbuffer[20];               /* Flawfinder: ignore */ 
		if (filename == "chat") 
		{ 
			strftime(dbuffer, 20, "-%Y-%m-%d", localtime(&now)); 
		} 
		else 
		{ 
			strftime(dbuffer, 20, "-%Y-%m", localtime(&now)); 
		} 
		filename += dbuffer; 
	}
	filename = cleanFileName(filename);
	filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_ACCOUNT_CHAT_LOGS,filename);
	filename += ".txt";
	return filename;
}