diff --git a/.gitignore b/.gitignore index 9782180..ed4eb5f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ debug release Makefile* qnapi +qnapic *.a win32/out/* win32/*.exe diff --git a/.travis.yml b/.travis.yml index 095addb..052d734 100644 --- a/.travis.yml +++ b/.travis.yml @@ -52,15 +52,17 @@ matrix: compiler: gcc env: - QT_BASE=59 + - os: linux + dist: trusty + sudo: required + compiler: gcc + env: + - QT_BASE=510 - os: osx compiler: clang env: - QT_BASE=55 - MAKE_DMG=1 - - os: osx - compiler: clang - env: - - QT_BASE=57 - os: osx compiler: clang env: @@ -76,8 +78,8 @@ before_install: - if [[ "$QT_BASE" = "57" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo add-apt-repository ppa:beineri/opt-qt571-trusty -y; fi - if [[ "$QT_BASE" = "58" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y; fi - if [[ "$QT_BASE" = "59" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo add-apt-repository ppa:beineri/opt-qt593-trusty -y; fi - - if [[ "$QT_BASE" = "510" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo add-apt-repository ppa:beineri/opt-qt510-trusty -y; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then + - if [[ "$QT_BASE" = "510" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo add-apt-repository ppa:beineri/opt-qt-5.10.1-trusty -y; fi + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq; else brew update; @@ -87,6 +89,7 @@ before_install: install: - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get install -qq libmediainfo-dev; fi + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then brew install mediainfo; fi - if [ "$TRAVIS_OS_NAME" = "osx" ]; then npm install -g appdmg; fi - if [[ "$QT_BASE" = "51" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo apt-get install -qq qt51base; source /opt/qt51/bin/qt51-env.sh; fi - if [[ "$QT_BASE" = "52" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo apt-get install -qq qt52base; source /opt/qt52/bin/qt52-env.sh; fi @@ -97,8 +100,8 @@ install: - if [[ "$QT_BASE" = "57" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo apt-get install -qq qt57base; source /opt/qt57/bin/qt57-env.sh; fi - if [[ "$QT_BASE" = "58" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo apt-get install -qq qt58base; source /opt/qt58/bin/qt58-env.sh; fi - if [[ "$QT_BASE" = "59" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo apt-get install -qq qt59base; source /opt/qt59/bin/qt59-env.sh; fi + - if [[ "$QT_BASE" = "510" && "$TRAVIS_OS_NAME" = "linux" ]]; then sudo apt-get install -qq qt510base; source /opt/qt510/bin/qt510-env.sh; fi - if [[ "$QT_BASE" = "55" && "$TRAVIS_OS_NAME" = "osx" ]]; then brew install qt@5.5; brew link --force qt@5.5; fi - - if [[ "$QT_BASE" = "57" && "$TRAVIS_OS_NAME" = "osx" ]]; then brew install qt@5.7; brew link --force qt@5.7; fi - if [[ "$QT_BASE" = "510" && "$TRAVIS_OS_NAME" = "osx" ]]; then brew install qt; brew link --force qt; fi diff --git a/Doxyfile b/Doxyfile index 3bea98c..beca163 100644 --- a/Doxyfile +++ b/Doxyfile @@ -791,6 +791,7 @@ WARN_LOGFILE = # Note: If this tag is empty the current directory is searched. INPUT = gui/src \ + cli/src \ libqnapi/src # This tag can be used to specify the character encoding of the source files diff --git a/README.md b/README.md index 66de5e2..a3543f3 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,10 @@ To compile the application, you have to execute two following commands in `qnapi This will produce `Makefile`. +> By appending `CONFIG+=no_cli` or `CONFIG+=no_gui` to qmake invocation you can disable building +> command-line or graphical interface binaries. + + `$ make` (or `mingw32-make` on Windows) This will compile the sources and build executable binary (or app bundle on OSX). diff --git a/appveyor.yml b/appveyor.yml index c0bfa85..dcff659 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,6 +13,12 @@ environment: MINGW: C:\Qt\Tools\mingw530_32 DEPLOY: 0 - QT5: C:\Qt\5.8\mingw53_32 + MINGW: C:\Qt\Tools\mingw530_32 + DEPLOY: 0 + - QT5: C:\Qt\5.9\mingw53_32 + MINGW: C:\Qt\Tools\mingw530_32 + DEPLOY: 0 + - QT5: C:\Qt\5.10.0\mingw53_32 MINGW: C:\Qt\Tools\mingw530_32 DEPLOY: 1 @@ -22,9 +28,8 @@ matrix: install: - appveyor-retry cinst nsis -y -version 2.51 - appveyor-retry cinst 7zip.commandline -y -x86 - - appveyor DownloadFile "http://nsis.sourceforge.net/mediawiki/images/archive/1/18/20140806212030!NsProcess.zip" -FileName NsProcess.zip - - 7z e -o"C:\Program Files (x86)\NSIS\Include" NsProcess.zip Include\*.nsh - - 7z e -o"C:\Program Files (x86)\NSIS\Plugins" NsProcess.zip Plugin\*.dll + - 7z e -o"C:\Program Files (x86)\NSIS\Include" deps\ns-process\NsProcess.zip Include\*.nsh + - 7z e -o"C:\Program Files (x86)\NSIS\Plugins" deps\ns-process\NsProcess.zip Plugin\*.dll - git submodule update --init --recursive before_build: diff --git a/cli/cli.pro b/cli/cli.pro new file mode 100644 index 0000000..7671dbb --- /dev/null +++ b/cli/cli.pro @@ -0,0 +1,47 @@ +TEMPLATE = app + +CONFIG += warn_on qt resources silent c++11 console + +QT += core network xml +QT -= gui + +SOURCES += src/main.cpp \ + src/clisubtitlesdownloader.cpp \ + src/climain.cpp + +HEADERS += \ + src/clisubtitlesdownloader.h \ + src/climain.h + +RESOURCES += res/resources.qrc + +MOC_DIR = tmp +RCC_DIR = tmp +OBJECTS_DIR = tmp +INCLUDEPATH = src + +include(../libqnapi/libqnapi.pri) + +unix { + TARGET = qnapic + DESTDIR = ../ + CONFIG += link_pkgconfig + PKGCONFIG += libmediainfo +} + +macx { + QT_CONFIG -= no-pkg-config + CONFIG -= app_bundle + LIBS += -framework CoreFoundation + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.8 + QMAKE_CXXFLAGS_X86_64 = -mmacosx-version-min=10.8 +} + +win32 { + CONFIG += nostrip + RC_FILE = ../win32/qnapi.rc + TARGET = qnapic + target.path = ../win32/out + INSTALLS += target +} + diff --git a/cli/res/resources.qrc b/cli/res/resources.qrc new file mode 100644 index 0000000..cfadbba --- /dev/null +++ b/cli/res/resources.qrc @@ -0,0 +1,6 @@ + + + ../../translations/qnapi_it.qm + ../../translations/qnapi_pl.qm + + diff --git a/cli/src/climain.cpp b/cli/src/climain.cpp new file mode 100644 index 0000000..442a729 --- /dev/null +++ b/cli/src/climain.cpp @@ -0,0 +1,140 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "climain.h" +#include "clisubtitlesdownloader.h" +#include "libqnapi.h" +#include "qnapicommand.h" +#include "subtitlelanguage.h" +#include "utils/helphelper.h" + +#include +#include +#include +#include + +namespace CliMain { + +void installTranslation(QCoreApplication &app, QTranslator *translator, + const QNapiConfig &config) { + QString uiLanguage = LibQNapi::uiLanguage(config.generalConfig()); + translator->load("qnapi_" + uiLanguage, ":/translations"); + app.installTranslator(translator); +} + +void printHeader(const Console &c) { + c.printLine(tr("QNapi %1 (Qt version %2), %3") + .arg(LibQNapi::displayableVersion()) + .arg(qVersion()) + .arg(LibQNapi::webpageUrl())); + c.printLine(); +} + +void printHelp(const Console &c, + const QList> &cliArgParsers) { + auto helpLines = HelpHelper::formatHelpLinesText(cliArgParsers); + foreach (auto helpLine, helpLines) { c.printLine(helpLine); } +} + +void printHelpLanguages(const Console &c, const QNapiConfig &config) { + c.printLine( + tr("List of languages recognized by QNapi, including corresponding")); + c.printLine(tr("two-letter language codes:")); + c.printLine(); + + SubtitleLanguage L, LB; + QStringList langs = L.listLanguages(); + + foreach (QString lang, langs) { + L.setLanguage(lang); + c.printLine(QString(" %1 - %2").arg(L.toTwoLetter()).arg(lang)); + } + + L.setLanguage(config.generalConfig().language()); + LB.setLanguage(config.generalConfig().backupLanguage()); + + c.printLine(); + c.printLine(tr("Current default subtitles language: %1 (%2)") + .arg(L.toFullName()) + .arg(L.toTwoLetter())); + + if (LB.toFullName().isEmpty()) { + c.printLine(tr("No alternative subtitles language has been set")); + } else { + c.printLine(tr("Current alternative subtitles language: %1 (%2)") + .arg(LB.toFullName()) + .arg(LB.toTwoLetter())); + } +} + +int processCommand(QVariant cliCommand, const QNapiConfig &config, + const QList> &cliArgParsers) { + const Console c(config.generalConfig().quietBatch()); + + printHeader(c); + + using namespace QNapiCommand; + if (cliCommand.canConvert()) { + QStringList movieFilePaths = + cliCommand.value().movieFilePaths; + return CliSubtitlesDownloader::downloadSubtitlesFor(c, movieFilePaths, + config); + } else if (cliCommand.canConvert()) { + printHelpLanguages(c, config); + return 0; + } else { + printHelp(c, cliArgParsers); + return 0; + } +} + +void sigHandler(int sig) { + Q_UNUSED(sig); + + std::cout << std::endl + << tr("QNapi: deleting temporary files...").toStdString() + << std::endl; + + const QNapiConfig config = LibQNapi::loadConfig(); + QString tmpPath = config.generalConfig().tmpPath(); + QDir tmpDir(tmpPath); + + QStringList filters; + filters << "QNapi-*-rc"; + filters << "QNapi.*.tmp"; + + QFileInfoList files = tmpDir.entryInfoList(filters); + + foreach (QFileInfo file, files) { QFile::remove(file.filePath()); } + + std::cout << tr("QNapi: finished.").toStdString() << std::endl; + + exit(666); +} + +void regSignal() { +#ifdef Q_OS_WIN + signal(SIGTERM, sigHandler); + signal(SIGINT, sigHandler); +#else + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); + sigemptyset(&sa.sa_mask); + sa.sa_handler = sigHandler; + sigaction(SIGTERM, &sa, 0); + sigaction(SIGINT, &sa, 0); +#endif +} + +} // namespace CliMain diff --git a/cli/src/climain.h b/cli/src/climain.h new file mode 100644 index 0000000..0970462 --- /dev/null +++ b/cli/src/climain.h @@ -0,0 +1,41 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef CLIMAIN_H +#define CLIMAIN_H + +#include "config/qnapiconfig.h" +#include "parser/cliargparser.h" +#include "parser/cliargparsersexecutor.h" +#include "tr.h" +#include "utils/console.h" + +namespace CliMain { + +Q_DECLARE_NAMESPACE_TR(CliMain) + +void installTranslation(QCoreApplication &app, QTranslator *translator, + const QNapiConfig &config); +void printHeader(const Console &c); +void printHelp(const Console &c, + const QList> &cliArgParsers); +void printHelpLanguages(const Console &c, const QNapiConfig &config); +int processCommand(QVariant cliCommand, const QNapiConfig &config, + const QList> &cliArgParsers); +void sigHandler(int sig); +void regSignal(); + +} // namespace CliMain + +#endif // CLIMAIN_H diff --git a/cli/src/clisubtitlesdownloader.cpp b/cli/src/clisubtitlesdownloader.cpp new file mode 100644 index 0000000..3e5e16a --- /dev/null +++ b/cli/src/clisubtitlesdownloader.cpp @@ -0,0 +1,238 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "clisubtitlesdownloader.h" +#include "qnapi.h" + +#include +#include + +namespace CliSubtitlesDownloader { + +enum ExitCode { + EC_OK = 0, + EC_P7ZIP_UNAVAILABLE = 2, + EC_CANNOT_WRITE_TMP_DIR = 3, + EC_NO_WRITE_PERMISSIONS = 5, + EC_SUBTITLES_NOT_FOUND = 6, + EC_COULD_NOT_DOWNLOAD = 7, + EC_COULD_NOT_UNARCHIVE = 8, + EC_COULD_NOT_MATCH = 9 +}; + +int configChecks(const Console& c, const QNapiConfig& config) { + QString p7zipPath = config.generalConfig().p7zipPath(); + if (!QFileInfo(p7zipPath).isExecutable()) { + c.printLine(tr("Invalid path to p7zip executable: %1").arg(p7zipPath)); + return EC_P7ZIP_UNAVAILABLE; + } + + QString tmpPath = config.generalConfig().tmpPath(); + QFileInfo tmp(tmpPath); + if (!tmp.isDir() || !tmp.isWritable()) { + c.printLine(tr("Can't write to temporary directory: %1").arg(tmpPath)); + return EC_CANNOT_WRITE_TMP_DIR; + } + + return EC_OK; +} + +bool findSubtitles(const Console& c, const QNapiConfig& config, QNapi& napi) { + bool found = false; + c.printLineOrdinary(tr("Calculating checksums...")); + napi.checksum(); + + SearchPolicy sp = config.generalConfig().searchPolicy(); + QString lang = config.generalConfig().language(); + QString langBackup = config.generalConfig().backupLanguage(); + + if (sp == SP_SEARCH_ALL_WITH_BACKUP_LANG) { + foreach (QString e, napi.listLoadedEngines()) { + c.printLineOrdinary( + tr("Searching for subtitles [%1] (%2)...").arg(lang, e)); + found = napi.lookForSubtitles(lang, e) || found; + c.printLineOrdinary( + tr("Searching for subtitles in alternative language [%1] (%2)...") + .arg(langBackup, e)); + found = napi.lookForSubtitles(langBackup, e) || found; + } + } else { + foreach (QString e, napi.listLoadedEngines()) { + c.printLineOrdinary( + tr("Searching for subtitles [%1] (%2)...").arg(lang, e)); + found = napi.lookForSubtitles(lang, e) || found; + + if (sp == SP_BREAK_IF_FOUND && found) break; + } + + if (!found && !langBackup.isEmpty()) { + foreach (QString e, napi.listLoadedEngines()) { + c.printLineOrdinary( + tr("Searching for subtitles in alternative language [%1] (%2)...") + .arg(langBackup, e)); + found = napi.lookForSubtitles(langBackup, e) || found; + + if (sp == SP_BREAK_IF_FOUND && found) break; + } + } + } + + return found; +} + +void printSubtitlesList(const Console& c, QNapi& napi) { + c.printLineOrdinary(tr("0)\tDo not download subtitles for this video")); + c.printLineOrdinary(tr("Found subtitles:")); + + int i = 1; + + foreach (SubtitleInfo s, napi.listSubtitles()) { + QString resolution = ""; + + if (s.resolution == SUBTITLE_GOOD) + resolution = tr(" (good)"); + else if (s.resolution == SUBTITLE_BAD) + resolution = tr(" (bad)"); + + c.printLineOrdinary(QString("%1)\t%2 (%3) (%4) (%5)%6") + .arg(i++) + .arg(s.name) + .arg(s.format) + .arg(s.lang) + .arg(s.engine) + .arg(resolution)); + } +} + +Maybe selectSubtitles(const Console& c, const QNapiConfig& config, + QNapi& napi) { + bool showList = false; + bool napiShowList = napi.needToShowList(); + + if(config.generalConfig().quietBatch() || config.generalConfig().downloadPolicy() == DP_NEVER_SHOW_LIST) { + showList = false; + } else if (config.generalConfig().downloadPolicy() == DP_ALWAYS_SHOW_LIST) { + showList = true; + } else { + showList = napiShowList; + } + + if (!showList) { + return just(napi.bestIdx()); + } else { + QList subtitlesList = napi.listSubtitles(); + + printSubtitlesList(c, napi); + int selIdx = c.inputNumber(tr("Select subtitles to download: "), 0, + subtitlesList.size()); + if (selIdx == 0) { + return nothing(); + } else { + return just(selIdx - 1); + } + } +} + +int finishSubtitles(int selIdx, const Console& c, QNapi& napi) { + c.printLineOrdinary(tr("Downloading subtitles...")); + if (!napi.download(selIdx)) { + c.printLineError(tr("Unable to download subtitles!")); + return EC_COULD_NOT_DOWNLOAD; + } + + c.printLineOrdinary(tr("Unpacking subtitles...")); + if (!napi.unpack(selIdx)) { + c.printLineError(tr("Failed to unpack subtitles!")); + return EC_COULD_NOT_UNARCHIVE; + } + + if (napi.ppEnabled()) { + c.printLineOrdinary(tr("Post-processing subtitles file...")); + napi.postProcessSubtitles(); + } + + c.printLineOrdinary(tr("Adjusting subtitles...")); + if (!napi.matchSubtitles()) { + c.printLineError(tr("Could not adjust subtitles!")); + return EC_COULD_NOT_MATCH; + } + + napi.cleanup(); + return 0; +} + +int downloadForMovie(const Console& c, const QString& movieFilePath, int i, + int total, const QNapiConfig& config, QNapi& napi) { + QString movieFileName = QFileInfo(movieFilePath).fileName(); + c.printLineHighlihted(tr("Downloading subtitles for '%1' [%2/%3]") + .arg(movieFileName) + .arg(i) + .arg(total)); + + napi.setMoviePath(movieFilePath); + + if (!napi.checkWritePermissions()) { + c.printLineError(tr("No permission to write to the directory '%1'!") + .arg(QFileInfo(movieFilePath).path())); + return EC_NO_WRITE_PERMISSIONS; + } + + napi.clearSubtitlesList(); + + bool found = findSubtitles(c, config, napi); + + if (!found) { + c.printLineWarning(tr("Subtitles not found!")); + return EC_SUBTITLES_NOT_FOUND; + } + + Maybe selIdx = selectSubtitles(c, config, napi); + + if (selIdx) { + return finishSubtitles(selIdx.value(), c, napi); + } + + napi.cleanup(); + + return EC_OK; +} + +int downloadSubtitlesFor(const Console& c, const QStringList& movieFilePaths, + const QNapiConfig& config) { + int ccErr = configChecks(c, config); + if (ccErr != 0) { + return ccErr; + } + + QNapi napi(config); + + int total = movieFilePaths.size(); + for (int i = 1; i <= total; ++i) { + QString movieFilePath = movieFilePaths[i - 1]; + + int result = downloadForMovie(c, movieFilePath, i, total, config, napi); + if (result == EC_P7ZIP_UNAVAILABLE || result == EC_CANNOT_WRITE_TMP_DIR) { + if (i < total) { + c.printLineOrdinary( + tr("Processing of remaining %n file(s) was ignored " + "due to critical error.", + "", total - i)); + } + return result; + } + } + + return EC_OK; +} +}; // namespace CliSubtitlesDownloader diff --git a/cli/src/clisubtitlesdownloader.h b/cli/src/clisubtitlesdownloader.h new file mode 100644 index 0000000..aa0417f --- /dev/null +++ b/cli/src/clisubtitlesdownloader.h @@ -0,0 +1,32 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef CLISUBTITLESDOWNLOADER_H +#define CLISUBTITLESDOWNLOADER_H + +#include "config/qnapiconfig.h" +#include "tr.h" +#include "utils/console.h" + +#include + +namespace CliSubtitlesDownloader { + +Q_DECLARE_NAMESPACE_TR(CliSubtitlesDownloader) + +int downloadSubtitlesFor(const Console& c, const QStringList& movieFilePaths, + const QNapiConfig& config); +}; // namespace CliSubtitlesDownloader + +#endif // CLISUBTITLESDOWNLOADER_H diff --git a/cli/src/main.cpp b/cli/src/main.cpp new file mode 100644 index 0000000..220b550 --- /dev/null +++ b/cli/src/main.cpp @@ -0,0 +1,89 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "Either.h" +#include "Maybe.h" +#include "climain.h" +#include "libqnapi.h" +#include "parser/backuplangargparser.h" +#include "parser/cliargparser.h" +#include "parser/cliargparsersexecutor.h" +#include "parser/dontshowlistargparser.h" +#include "parser/downloadsubtitlesargparser.h" +#include "parser/extensionargparser.h" +#include "parser/formatargparser.h" +#include "parser/langargparser.h" +#include "parser/quietbatchargparser.h" +#include "parser/showhelpargparser.h" +#include "parser/showhelplanguagesargparser.h" +#include "parser/showlistargparser.h" +#include "qnapicommand.h" +#include "utils/console.h" + +#include +#include +#include + +int main(int argc, char **argv) { + LibQNapi::init(argv[0]); + + const QNapiConfig config = LibQNapi::loadConfig(); + + QCoreApplication cliApp(argc, argv); + + CliMain::regSignal(); + + QTranslator qnapiTranslator; + CliMain::installTranslation(cliApp, &qnapiTranslator, config); + + const QList> cliArgParsers = { + QSharedPointer(new ShowHelpArgParser()), + QSharedPointer(new ShowHelpLanguagesArgParser()), + QSharedPointer(new QuietBatchArgParser()), + QSharedPointer(new ShowListArgParser()), + QSharedPointer(new DontShowListArgParser()), + QSharedPointer(new LangArgParser()), + QSharedPointer(new BackupLangArgParser()), + QSharedPointer(new FormatArgParser()), + QSharedPointer(new ExtensionArgParser()), + QSharedPointer(new DownloadSubtitlesArgParser())}; + + QStringList tailArgs = + cliApp.arguments().mid(1, cliApp.arguments().size() - 1); + + auto parseResult = + CliArgParsersExecutor::executeParsers(cliArgParsers, tailArgs, config); + + const Console c; + + if (parseResult.is>()) { + auto parsedMaybeCommand = + parseResult.as>(); + + if (parsedMaybeCommand) { + auto parsedCommand = parsedMaybeCommand.value(); + return CliMain::processCommand( + parsedCommand.command, parsedCommand.refinedConfig, cliArgParsers); + } else { + CliMain::printHeader(c); + CliMain::printHelp(c, cliArgParsers); + return 0; + } + } else { + CliMain::printHeader(c); + c.printLine(CliMain::tr("Command line argument parsing error:")); + c.printLine(parseResult.as()); + return -1; + } +} diff --git a/deps/ns-process/NsProcess.zip b/deps/ns-process/NsProcess.zip new file mode 100644 index 0000000..d05fe69 Binary files /dev/null and b/deps/ns-process/NsProcess.zip differ diff --git a/gui/gui.pro b/gui/gui.pro index 8d13ecd..d0e0d3f 100644 --- a/gui/gui.pro +++ b/gui/gui.pro @@ -1,17 +1,8 @@ TEMPLATE = app -CONFIG += warn_on \ - thread \ - qt \ - resources \ - silent \ - c++11 +CONFIG += warn_on qt resources silent c++11 -QT += network \ - gui \ - widgets \ - core \ - xml +QT += core network xml gui widgets SOURCES += src/main.cpp \ src/forms/frmprogress.cpp \ @@ -30,8 +21,7 @@ SOURCES += src/main.cpp \ src/qcumber/qsingleapplication.cpp \ src/qnapiopendialog.cpp \ src/qnapiapp.cpp \ - src/qnapicli.cpp \ - src/qnapi.cpp + src/guimain.cpp HEADERS += src/forms/frmprogress.h \ src/forms/frmlistsubtitles.h \ @@ -52,8 +42,7 @@ HEADERS += src/forms/frmprogress.h \ src/qnapithread.h \ src/qnapiopendialog.h \ src/qnapiapp.h \ - src/qnapicli.h \ - src/qnapi.h + src/guimain.h FORMS += ui/frmprogress.ui \ ui/frmlistsubtitles.ui \ @@ -87,13 +76,12 @@ macx { SOURCES += src/utils/infoplistdockicon.cpp HEADERS += src/utils/infoplistdockicon.h - LIBS += -framework CoreFoundation - TARGET = QNapi DESTDIR = ../macx/ - QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 - QMAKE_CXXFLAGS_X86_64 = -mmacosx-version-min=10.7 + LIBS += -framework CoreFoundation + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.8 + QMAKE_CXXFLAGS_X86_64 = -mmacosx-version-min=10.8 ICON = ../macx/qnapi.icns QMAKE_INFO_PLIST = ../macx/Info.plist 7ZIP_BINARY.files = ../macx/content/7za @@ -105,14 +93,10 @@ macx { win32 { CONFIG += nostrip - SOURCES += src/qcumber/qinterprocesschannel_win32.cpp HEADERS += src/qcumber/qinterprocesschannel_win32.h - RC_FILE = ../win32/qnapi.rc - TARGET = qnapi - target.path = ../win32/out INSTALLS += target } diff --git a/gui/src/forms/frmprogress.cpp b/gui/src/forms/frmprogress.cpp index e5a21d1..e5e2453 100644 --- a/gui/src/forms/frmprogress.cpp +++ b/gui/src/forms/frmprogress.cpp @@ -53,7 +53,7 @@ frmProgress::frmProgress(QWidget *parent, Qt::WindowFlags f) void frmProgress::receiveRequest(const QString &request) { enqueueFile(request); - if (!getThread.isRunning()) download(); + if (!getThread.isRunning()) download(LibQNapi::loadConfig()); raise(); activateWindow(); } @@ -74,24 +74,12 @@ void frmProgress::enqueueFiles(const QStringList &fileList) { } } -bool frmProgress::download() { +bool frmProgress::download(const QNapiConfig &config) { if (summary.isVisible()) { summary.close(); } - auto config = LibQNapi::loadConfig(); - auto config1 = config; - if (!targetFormatOverride.isEmpty()) { - config1 = config1.setPostProcessingConfig( - config1.postProcessingConfig().setSubFormat(targetFormatOverride)); - } - auto config2 = config1; - if (!targetExtOverride.isEmpty()) { - config2 = config2.setPostProcessingConfig( - config2.postProcessingConfig().setSubExtension(targetExtOverride)); - } - - QNapi napi(config2); + QNapi napi(config); // TODO: perform these checks earlier if (!napi.checkP7ZipPath()) { @@ -125,7 +113,7 @@ bool frmProgress::download() { closeRequested = false; ui.pbCancel->setEnabled(true); - getThread.setConfig(config2); + getThread.setConfig(config); getThread.start(); return true; } @@ -236,8 +224,7 @@ void frmProgress::dropEvent(QDropEvent *event) { } } -GetThread::GetThread() - : langBackupPassed(false), config(LibQNapi::loadConfig()) { +GetThread::GetThread() : config(LibQNapi::loadConfig()) { connect(this, SIGNAL(criticalError(const QString &)), this, SLOT(setCriticalMessage(const QString &))); } @@ -266,9 +253,8 @@ void GetThread::run() { emit progressChange(0, queue.size(), 0.0f); - QString language = !lang.isEmpty() ? lang : config.generalConfig().language(); - QString languageBackup = - langBackupPassed ? langBackup : config.generalConfig().backupLanguage(); + QString language = config.generalConfig().language(); + QString languageBackup = config.generalConfig().backupLanguage(); for (int i = 0; i < queue.size(); i++) { ABORT_POINT diff --git a/gui/src/forms/frmprogress.h b/gui/src/forms/frmprogress.h index 79aa584..7dbcdcf 100644 --- a/gui/src/forms/frmprogress.h +++ b/gui/src/forms/frmprogress.h @@ -50,12 +50,6 @@ class GetThread : public QNapiThread { public: void setSpecificEngine(Maybe engine) { specificEngine = engine; } - void setLanguages(QString language, QString languageBackup, - bool languageBackupPassed) { - lang = language; - langBackup = languageBackup; - langBackupPassed = languageBackupPassed; - } void setConfig(const QNapiConfig &configuration) { config = configuration; } void run(); @@ -63,8 +57,6 @@ class GetThread : public QNapiThread { QStringList queue; Maybe specificEngine; QList subStatusList; - QString lang, langBackup; - bool langBackupPassed; int napiSuccess, napiFail; QString criticalMessage; QMutex waitForDlg; @@ -84,12 +76,6 @@ class frmProgress : public QWidget { } void setBatchMode(bool value) { batchMode = value; } - void setBatchLanguages(QString lang, QString langBackup, - bool langBackupPassed) { - getThread.setLanguages(lang, langBackup, langBackupPassed); - } - void setTargetFormatOverride(QString value) { targetFormatOverride = value; } - void setTargetExtOverride(QString value) { targetExtOverride = value; } bool isBatchMode() { return batchMode; } signals: @@ -99,7 +85,7 @@ class frmProgress : public QWidget { void receiveRequest(const QString &request); void enqueueFile(const QString &file); void enqueueFiles(const QStringList &fileList); - bool download(); + bool download(const QNapiConfig &config); void updateProgress(int current, int all, float stageProgress); void selectSubtitles(QString fileName, SubtitleInfoList subtitles); void downloadFinished(); @@ -113,7 +99,6 @@ class frmProgress : public QWidget { GetThread getThread; frmListSubtitles frmSelect; frmSummary summary; - QString targetFormatOverride, targetExtOverride; bool batchMode, showSummary, closeRequested; QMutex mutex; diff --git a/gui/src/guimain.cpp b/gui/src/guimain.cpp new file mode 100644 index 0000000..e54b404 --- /dev/null +++ b/gui/src/guimain.cpp @@ -0,0 +1,234 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "guimain.h" +#include +#include +#include +#include +#include +#include +#include +#include "config/qnapiconfig.h" +#include "libqnapi.h" +#include "qnapicommand.h" +#include "utils/helphelper.h" + +namespace GuiMain { + +int processCommand(QNapiApp &app, QVariant cliCommand, + const QNapiConfig &config, + const QList> &cliArgParsers) { + using namespace QNapiCommand; + + if (cliCommand.canConvert()) { + QStringList cliArgs = cliCommand.value().arguments; + return GuiMain::runCLI(cliArgs); + + } else if (cliCommand.canConvert()) { + auto helpLines = HelpHelper::formatHelpLinesText(cliArgParsers, 30, 64); + + showHelpText(helpLines.join("\n")); + + return 0; + } else if (cliCommand.canConvert()) { + showHelpLanguages(config); + + return 0; + } else if (cliCommand.canConvert()) { + app.showSettings(); + return 0; + + } else if (cliCommand.canConvert()) { + app.setQuitOnLastWindowClosed(true); + app.progress()->setBatchMode(true); + app.showScanDialog(config, cliCommand.value().directory); + return app.exec(); + + } else if (cliCommand.canConvert()) { + QStringList movieFilePaths = + cliCommand.value().movieFilePaths; + + if (!app.isInstanceAllowed()) { + foreach (QString movieFilePath, movieFilePaths) { + QFileInfo fi(movieFilePath); + app.sendRequest(fi.absoluteFilePath()); + } + return 0; + } + + app.setQuitOnLastWindowClosed(true); + app.progress()->setBatchMode(true); + app.progress()->enqueueFiles(movieFilePaths); + app.progress()->download(config); + return app.exec(); + } + + return 1; +} + +void showHelpText(const QString &helpText) { + QMessageBox helpDialog(QMessageBox::Information, "QNapi", helpText, + QMessageBox::Close); + + QSpacerItem *horizontalSpacer = + new QSpacerItem(720, 0, QSizePolicy::Minimum, QSizePolicy::Expanding); + QGridLayout *layout = (QGridLayout *)helpDialog.layout(); + layout->addItem(horizontalSpacer, layout->rowCount(), 0, 1, + layout->columnCount()); + + helpDialog.setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); + helpDialog.exec(); +} + +void showHelpLanguages(const QNapiConfig &config) { + QStringList helpLanguagesLines; + helpLanguagesLines << tr( + "List of languages recognized by QNapi, including corresponding"); + helpLanguagesLines << tr("two-letter language codes:"); + helpLanguagesLines << ""; + + SubtitleLanguage L, LB; + QStringList langs = L.listLanguages(); + + foreach (QString lang, langs) { + L.setLanguage(lang); + helpLanguagesLines << QString(" %1 - %2").arg(L.toTwoLetter()).arg(lang); + } + + L.setLanguage(config.generalConfig().language()); + LB.setLanguage(config.generalConfig().backupLanguage()); + + helpLanguagesLines << ""; + helpLanguagesLines << tr("Current default subtitles language: %1 (%2)") + .arg(L.toFullName()) + .arg(L.toTwoLetter()); + + if (LB.toFullName().isEmpty()) { + helpLanguagesLines << tr("No alternative subtitles language has been set"); + } else { + helpLanguagesLines << tr("Current alternative subtitles language: %1 (%2)") + .arg(LB.toFullName()) + .arg(LB.toTwoLetter()); + } + + showHelpText(helpLanguagesLines.join("\n")); +} + +void showArgParserError(const QString &errorMessage) { + QMessageBox::critical(0, tr("QNapi - command line argument parsing error"), + errorMessage, QMessageBox::Close); +} + +static QString cliExecutableName = +#ifdef Q_OS_WIN + "qnapic.exe"; +#else + "qnapic"; +#endif + +Maybe cliExecutablePath() { + QStringList searchPaths = {LibQNapi::appExecutableDir}; + +#ifndef Q_OS_WIN + searchPaths << QProcess::systemEnvironment() + .filter(QRegExp("^PATH=(.*)$")) + .value(0) + .mid(5) + .split(":") + << "/bin" + << "/usr/bin" + << "/usr/local/bin"; + searchPaths.removeAll(""); +#endif + + foreach (QString path, searchPaths) { + QString candidate = path + QDir::separator() + cliExecutableName; + if (QFileInfo(candidate).isExecutable()) { + return just(candidate); + } + } + + return nothing(); +} + +bool isCLIAvailable() { return cliExecutablePath(); } + +int runCLI(const QStringList &args) { + auto maybeCliExecutablePath = cliExecutablePath(); + if (!maybeCliExecutablePath) { + QMessageBox::critical(0, tr("QNapi - CLI executable not found"), + tr("You have requested to run QNapi in command-line " + "mode, but unfortunately command-line binary '%1' " + "could not be found.") + .arg(cliExecutableName), + QMessageBox::Close); + return 1; + } else { + return QProcess::execute(maybeCliExecutablePath.value(), args); + } +} + +void installTranslation(QCoreApplication &app, QTranslator *qtTranslator, + QTranslator *translator, const QNapiConfig &config) { + QString uiLanguage = LibQNapi::uiLanguage(config.generalConfig()); + + QString resourceDir = QLibraryInfo::location(QLibraryInfo::TranslationsPath); + + qtTranslator->load("qt_" + uiLanguage, resourceDir); + app.installTranslator(qtTranslator); + + translator->load("qnapi_" + uiLanguage, ":/translations"); + app.installTranslator(translator); +} + +void regSignal() { +#ifdef Q_OS_WIN + signal(SIGTERM, sigHandler); + signal(SIGINT, sigHandler); +#else + struct sigaction sa; + memset(&sa, 0, sizeof(struct sigaction)); + sigemptyset(&sa.sa_mask); + sa.sa_handler = sigHandler; + sigaction(SIGTERM, &sa, 0); + sigaction(SIGINT, &sa, 0); +#endif +} + +void sigHandler(int sig) { + Q_UNUSED(sig); + + std::cout << std::endl + << QObject::tr("QNapi: deleting temporary files...").toStdString() + << std::endl; + + const QNapiConfig config = LibQNapi::loadConfig(); + QString tmpPath = config.generalConfig().tmpPath(); + QDir tmpDir(tmpPath); + + QStringList filters; + filters << "QNapi-*-rc"; + filters << "QNapi.*.tmp"; + + QFileInfoList files = tmpDir.entryInfoList(filters); + + foreach (QFileInfo file, files) { QFile::remove(file.filePath()); } + + std::cout << QObject::tr("QNapi: finished.").toStdString() << std::endl; + + exit(666); +} + +} // namespace GuiMain diff --git a/gui/src/guimain.h b/gui/src/guimain.h new file mode 100644 index 0000000..07f7abd --- /dev/null +++ b/gui/src/guimain.h @@ -0,0 +1,44 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef GUIMAIN_H +#define GUIMAIN_H + +#include "config/qnapiconfig.h" +#include "parser/cliargparser.h" +#include "qnapiapp.h" +#include "tr.h" + +#include +#include + +namespace GuiMain { +Q_DECLARE_NAMESPACE_TR(GuiMain) + +int processCommand(QNapiApp &app, QVariant cliCommand, + const QNapiConfig &config, + const QList> &cliArgParsers); +void showHelpText(const QString &helpText); +void showHelpLanguages(const QNapiConfig &config); +void showArgParserError(const QString &errorMessage); + +bool isCLIAvailable(); +int runCLI(const QStringList &args); +void installTranslation(QCoreApplication &app, QTranslator *qtTranslator, + QTranslator *translator, const QNapiConfig &config); +void regSignal(); +void sigHandler(int); +} // namespace GuiMain + +#endif // GUIMAIN_H diff --git a/gui/src/main.cpp b/gui/src/main.cpp index 2b0c60b..1be4a09 100644 --- a/gui/src/main.cpp +++ b/gui/src/main.cpp @@ -12,228 +12,100 @@ ** *****************************************************************************/ -#include -#include -#include -#include #include #include -#include -#include #include +#include + +#include "Either.h" +#include "Maybe.h" +#include "guimain.h" #include "libqnapi.h" +#include "parser/backuplangargparser.h" +#include "parser/cliargparser.h" +#include "parser/cliargparsersexecutor.h" +#include "parser/dontshowlistargparser.h" +#include "parser/downloadsubtitlesargparser.h" +#include "parser/extensionargparser.h" +#include "parser/formatargparser.h" +#include "parser/langargparser.h" +#include "parser/quietbatchargparser.h" +#include "parser/runcliappargparser.h" +#include "parser/scandirectoryargparser.h" +#include "parser/showhelpargparser.h" +#include "parser/showhelplanguagesargparser.h" +#include "parser/showlistargparser.h" +#include "parser/showoptionsargparser.h" #include "qnapiapp.h" -#include "qnapicli.h" - -QStringList parseArgs(int argc, char **argv); -void regSignal(); -void sigHandler(int); int main(int argc, char **argv) { LibQNapi::init(argv[0]); const QNapiConfig config = LibQNapi::loadConfig(); - QString uiLanguage = LibQNapi::uiLanguage(config.generalConfig()); - - bool isCliCall = QNapiCli::isCliCall(argc, argv); - - QStringList parsedFilePaths = parseArgs(argc, argv); - - regSignal(); - - bool quietBatch = config.generalConfig().quietBatch(); -#ifdef Q_OS_MAC - quietBatch = false; -#endif - - bool useGui = !isCliCall && !(quietBatch && !parsedFilePaths.isEmpty()); - - if (useGui) { - QNapiApp app(argc, argv, true, "QNapi"); - - QString resourceDir = - QLibraryInfo::location(QLibraryInfo::TranslationsPath); - - QTranslator qtTranslator, qnapiTranslator; - qtTranslator.load("qt_" + uiLanguage, resourceDir); - app.installTranslator(&qtTranslator); - - qnapiTranslator.load("qnapi_" + uiLanguage, ":/translations"); - app.installTranslator(&qnapiTranslator); - - app.setQuitOnLastWindowClosed(false); - - if (app.arguments().contains("-o") || - app.arguments().contains("--options")) { - app.setQuitOnLastWindowClosed(true); - app.showSettings(); - return 0; - } - - if (!app.isInstanceAllowed()) { - for (int i = 0; i < parsedFilePaths.size(); i++) { - QString &fileName = parsedFilePaths[i]; - QFileInfo fi(fileName); - app.sendRequest(fi.absoluteFilePath()); - } - return 0; - } - - if (config.firstrun()) { - if (QMessageBox::question(0, QObject::tr("First Run"), - QObject::tr("This is the first launch of the " - "program QNapi. Do you want to " - "configure it now?"), - QMessageBox::Yes | QMessageBox::No) == - QMessageBox::Yes) { - app.showSettings(); - } - } - - // Jesli podano parametry, ustawiamy tzw. batch mode - if (parsedFilePaths.size() > 0) { - app.progress()->setBatchMode(true); - - QString p, batchLang, batchLangBackup; - bool invalidLang = false, batchLangBackupPassed = false; - - for (int i = 1; i < argc; i++) { - p = argv[i]; - - if ((p == "-l") || (p == "--lang")) { - ++i; - if (i < argc) { - batchLang = SubtitleLanguage(argv[i]).toTwoLetter(); - if (batchLang.isEmpty()) { - invalidLang = true; - } - } else { - invalidLang = true; - } - } else if ((p == "-lb") || (p == "--lang-backup")) { - ++i; - if (i < argc) { - batchLangBackup = SubtitleLanguage(argv[i]).toTwoLetter(); - batchLangBackupPassed = true; - } - break; - } else if ((p == "--format") || (p == "-f")) { - ++i; - if (i < argc) { - if (!LibQNapi::subtitleFormatsRegistry() - ->select(argv[i]) - .isNull()) { - app.progress()->setTargetFormatOverride(argv[i]); - } - } - } else if ((p == "--extension") || (p == "-e")) { - ++i; - if (i < argc) { - app.progress()->setTargetExtOverride(argv[i]); + QNapiApp app(argc, argv, "QNapi"); + + GuiMain::regSignal(); + + QTranslator qtTranslator, qnapiTranslator; + GuiMain::installTranslation(app, &qtTranslator, &qnapiTranslator, config); + + QList> cliArgParsers = { + QSharedPointer(new ShowHelpArgParser()), + QSharedPointer(new ShowHelpLanguagesArgParser()), + QSharedPointer(new RunCLIAppArgParser()), + QSharedPointer(new QuietBatchArgParser()), + QSharedPointer(new ShowListArgParser()), + QSharedPointer(new DontShowListArgParser()), + QSharedPointer(new LangArgParser()), + QSharedPointer(new BackupLangArgParser()), + QSharedPointer(new FormatArgParser()), + QSharedPointer(new ExtensionArgParser()), + QSharedPointer(new ShowOptionsArgParser()), + QSharedPointer(new ScanDirectoryArgParser()), + QSharedPointer(new DownloadSubtitlesArgParser())}; + + QStringList tailArgs = app.arguments().mid(1, app.arguments().size() - 1); + + auto parseResult = + CliArgParsersExecutor::executeParsers(cliArgParsers, tailArgs, config); + + if (parseResult.is>()) { + auto parsedMaybeCommand = + parseResult.as>(); + + if (parsedMaybeCommand) { + auto parsedCommand = parsedMaybeCommand.value(); + return GuiMain::processCommand(app, parsedCommand.command, + parsedCommand.refinedConfig, + cliArgParsers); + } else { + if (app.isInstanceAllowed()) { + if (config.firstrun()) { + if (QMessageBox::question( + 0, QObject::tr("First Run"), + QObject::tr("This is the first launch of the " + "program QNapi. Do you want to " + "configure it now?"), + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { + app.showSettings(); } } - } - - if (invalidLang) { - if (QMessageBox::question(0, "QNapi", - "Invalid language code!\n" - "Do you want to download the subtitles in " - "the default language?", - QMessageBox::Yes | QMessageBox::No) != - QMessageBox::Yes) { - return 0; - } - } - - app.progress()->setBatchLanguages(batchLang, batchLangBackup, - batchLangBackupPassed); - - if (QFileInfo(parsedFilePaths.at(0)).isDir()) { - if (!app.showScanDialog(parsedFilePaths.at(0))) return 1; - } else { - app.progress()->enqueueFiles(parsedFilePaths); - if (!app.progress()->download()) return 1; - } - } - // Jesli nie dzialamy w trybie pobierania, mozemy ew. utworzyc ikone w - // tray-u badz pokazac okno wyboru plikow z filmami - if (!app.progress()->isBatchMode()) { - // Jesli nie ma traya, od razu wyswietlamy okienko z wyborem pliku - if (!QSystemTrayIcon::isSystemTrayAvailable()) { - if (!app.progress()->isBatchMode()) { - app.progress()->setBatchMode(true); - if (!app.showOpenDialog()) return 1; + if (!QSystemTrayIcon::isSystemTrayAvailable()) { + app.setQuitOnLastWindowClosed(true); + if (!app.showOpenDialog(config)) return 1; + } else { + app.setQuitOnLastWindowClosed(false); + app.createTrayIcon(); } - } else // Jesli ikona w tray-u jest obsligiwana, tworzymy ja - { - app.createTrayIcon(); + app.exec(); } + return 0; } - return app.exec(); } else { - QNapiCli app(argc, argv, config, uiLanguage); - return app.exec(); - } -} - -QStringList parseArgs(int argc, char **argv) { - QStringList parsedFilePaths; - - for (int i = 1; i < argc; i++) { -#ifdef Q_OS_WIN - QString p = QString::fromLocal8Bit(argv[i]); -#else - QString p = argv[i]; -#endif - if (p.startsWith("file://")) p = p.remove(0, 7); - - if ((parsedFilePaths.size() == 0) && QFileInfo(p).isDir()) { - parsedFilePaths << p; - break; - } - - if (QFileInfo(p).isFile()) parsedFilePaths << p; + GuiMain::showArgParserError(parseResult.as()); + return 1; } - return parsedFilePaths; -} - -void regSignal() { -#ifdef Q_OS_WIN - signal(SIGTERM, sigHandler); - signal(SIGINT, sigHandler); -#else - struct sigaction sa; - memset(&sa, 0, sizeof(struct sigaction)); - sigemptyset(&sa.sa_mask); - sa.sa_handler = sigHandler; - sigaction(SIGTERM, &sa, 0); - sigaction(SIGINT, &sa, 0); -#endif -} - -void sigHandler(int sig) { - Q_UNUSED(sig); - - std::cout << std::endl - << QObject::tr("QNapi: deleting temporary files...").toStdString() - << std::endl; - - const QNapiConfig config = LibQNapi::loadConfig(); - QString tmpPath = config.generalConfig().tmpPath(); - QDir tmpDir(tmpPath); - - QStringList filters; - filters << "QNapi-*-rc"; - filters << "QNapi.*.tmp"; - - QFileInfoList files = tmpDir.entryInfoList(filters); - - foreach (QFileInfo file, files) { QFile::remove(file.filePath()); } - - std::cout << QObject::tr("QNapi: finished.").toStdString() << std::endl; - - exit(666); } diff --git a/gui/src/qcumber/qsingleapplication.cpp b/gui/src/qcumber/qsingleapplication.cpp index 723ad7d..5e75f18 100644 --- a/gui/src/qcumber/qsingleapplication.cpp +++ b/gui/src/qcumber/qsingleapplication.cpp @@ -23,9 +23,9 @@ /*! \brief Constructor */ -QSingleApplication::QSingleApplication(int& argc, char** argv, bool useGui, +QSingleApplication::QSingleApplication(int& argc, char** argv, const QString& appName) - : QApplication(argc, argv, useGui) { + : QApplication(argc, argv) { setApplicationName(appName); pChannel = new QInterProcessChannel(this); diff --git a/gui/src/qcumber/qsingleapplication.h b/gui/src/qcumber/qsingleapplication.h index 546dbfb..219c0d8 100644 --- a/gui/src/qcumber/qsingleapplication.h +++ b/gui/src/qcumber/qsingleapplication.h @@ -36,8 +36,7 @@ class QCUMBER_EXPORT QSingleApplication : public QApplication { enum MessagingPolicy { Ignore, Events, Signals }; - QSingleApplication(int& argc, char** argv, bool useGui, - const QString& appName); + QSingleApplication(int& argc, char** argv, const QString& appName); virtual ~QSingleApplication(); bool isInstanceAllowed() const; diff --git a/gui/src/qnapiapp.cpp b/gui/src/qnapiapp.cpp index 8fd31a8..9469d08 100644 --- a/gui/src/qnapiapp.cpp +++ b/gui/src/qnapiapp.cpp @@ -14,10 +14,11 @@ #include "qnapiapp.h" +#include #include "libqnapi.h" -QNapiApp::QNapiApp(int &argc, char **argv, bool useGui, const QString &appName) - : QSingleApplication(argc, argv, useGui, appName), +QNapiApp::QNapiApp(int &argc, char **argv, const QString &appName) + : QSingleApplication(argc, argv, appName), creationDT(QDateTime::currentDateTime()), enginesRegistry(LibQNapi::subtitleDownloadEngineRegistry()) { setAttribute(Qt::AA_UseHighDpiPixmaps, true); @@ -43,6 +44,7 @@ QNapiApp::QNapiApp(int &argc, char **argv, bool useGui, const QString &appName) napiSubMenu = 0; osSubMenu = 0; + napisy24SubMenu = 0; trayIconMenu = 0; trayIcon = 0; } @@ -68,6 +70,8 @@ QNapiApp::~QNapiApp() { if (quitAction) delete quitAction; if (napiSubMenu) delete napiSubMenu; + if (osSubMenu) delete osSubMenu; + if (napisy24SubMenu) delete napisy24SubMenu; if (trayIconMenu) delete trayIconMenu; if (trayIcon) delete trayIcon; } @@ -86,17 +90,19 @@ frmProgress *QNapiApp::progress() { void QNapiApp::createTrayIcon() { getAction = new QAction(tr("Download subtitles"), 0); - connect(getAction, SIGNAL(triggered()), this, SLOT(showOpenDialog())); + connect(getAction, &QAction::triggered, + [this] { showOpenDialog(LibQNapi::loadConfig()); }); scanAction = new QAction(tr("Scan directories"), 0); - connect(scanAction, SIGNAL(triggered()), this, SLOT(showScanDialog())); + connect(scanAction, &QAction::triggered, + [this] { showScanDialog(LibQNapi::loadConfig()); }); convertAction = new QAction(tr("Convert subtitles"), 0); connect(convertAction, SIGNAL(triggered()), this, SLOT(showConvertDialog())); napiGetAction = new QAction(tr("Download subtitles"), 0); connect(napiGetAction, &QAction::triggered, - [this] { showOpenDialog("NapiProjekt"); }); + [this] { showOpenDialog(LibQNapi::loadConfig(), "NapiProjekt"); }); napiCreateUserAction = new QAction(tr("Create an account"), 0); connect(napiCreateUserAction, &QAction::triggered, @@ -104,7 +110,7 @@ void QNapiApp::createTrayIcon() { osGetAction = new QAction(tr("Download subtitles"), 0); connect(osGetAction, &QAction::triggered, - [this] { showOpenDialog("OpenSubtitles"); }); + [this] { showOpenDialog(LibQNapi::loadConfig(), "OpenSubtitles"); }); osAddAction = new QAction(tr("Upload subtitles"), 0); connect(osAddAction, SIGNAL(triggered()), this, SLOT(showOSUploadDialog())); @@ -115,7 +121,7 @@ void QNapiApp::createTrayIcon() { napisy24GetAction = new QAction(tr("Download subtitles"), 0); connect(napisy24GetAction, &QAction::triggered, - [this] { showOpenDialog("Napisy24"); }); + [this] { showOpenDialog(LibQNapi::loadConfig(), "Napisy24"); }); napisy24CreateUserAction = new QAction(tr("Create an account"), 0); connect(napisy24CreateUserAction, &QAction::triggered, @@ -175,11 +181,11 @@ void QNapiApp::showTrayMessage(QString title, QString msg) { trayIcon->showMessage(title, msg); } -bool QNapiApp::showOpenDialog(QString engine) { +bool QNapiApp::showOpenDialog(const QNapiConfig &config, QString engine) { QStringList fileList; if (!openDialog) { - QString initDir = LibQNapi::loadConfig().lastOpenedDir(); + QString initDir = config.lastOpenedDir(); if (!QFileInfo(initDir).isDir()) { initDir = QDir::homePath(); @@ -201,8 +207,7 @@ bool QNapiApp::showOpenDialog(QString engine) { if (!fileList.isEmpty()) { QString dialogPath = QFileInfo(fileList.first()).absolutePath(); - auto newConfig = LibQNapi::loadConfig().setLastOpenedDir(dialogPath); - LibQNapi::writeConfig(newConfig); + LibQNapi::writeConfig(config.setLastOpenedDir(dialogPath)); } } @@ -217,7 +222,7 @@ bool QNapiApp::showOpenDialog(QString engine) { } progress()->enqueueFiles(fileList); - progress()->download(); + progress()->download(config); } else if (progress()->isBatchMode()) { return false; } @@ -225,7 +230,7 @@ bool QNapiApp::showOpenDialog(QString engine) { return true; } -bool QNapiApp::showScanDialog(QString init_dir) { +bool QNapiApp::showScanDialog(const QNapiConfig &config, QString init_dir) { if (!f_scan) f_scan = new frmScan(); if (f_scan->isVisible()) { @@ -240,7 +245,7 @@ bool QNapiApp::showScanDialog(QString init_dir) { if (f_scan->exec() == QDialog::Accepted) { result = true; progress()->enqueueFiles(f_scan->getSelectedFiles()); - progress()->download(); + progress()->download(config); } delete f_scan; @@ -258,8 +263,8 @@ void QNapiApp::showConvertDialog() { f_convert->exec(); - delete f_scan; - f_scan = 0; + delete f_convert; + f_convert = 0; } void QNapiApp::showCreateAccount(const QString &engineName) const { @@ -311,7 +316,7 @@ void QNapiApp::tryQuit() { void QNapiApp::trayIconActivated(QSystemTrayIcon::ActivationReason reason) { if (reason == QSystemTrayIcon::Trigger) #ifndef Q_OS_MAC - showOpenDialog() + showOpenDialog(LibQNapi::loadConfig()) #endif ; } diff --git a/gui/src/qnapiapp.h b/gui/src/qnapiapp.h index 0fa0661..70275d3 100644 --- a/gui/src/qnapiapp.h +++ b/gui/src/qnapiapp.h @@ -42,7 +42,7 @@ class QNapiApp : public QSingleApplication { Q_OBJECT public: - QNapiApp(int &argc, char **argv, bool useGui, const QString &appName); + QNapiApp(int &argc, char **argv, const QString &appName); ~QNapiApp(); void createTrayIcon(); @@ -52,8 +52,8 @@ class QNapiApp : public QSingleApplication { public slots: - bool showOpenDialog(QString engine = ""); - bool showScanDialog(QString init_dir = ""); + bool showOpenDialog(const QNapiConfig &config, QString engine = ""); + bool showScanDialog(const QNapiConfig &config, QString init_dir = ""); void showConvertDialog(); void showCreateAccount(const QString &engineName) const; void showOSUploadDialog() const; diff --git a/gui/src/qnapicli.cpp b/gui/src/qnapicli.cpp deleted file mode 100644 index 356461a..0000000 --- a/gui/src/qnapicli.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/***************************************************************************** -** QNapi -** Copyright (C) 2008-2017 Piotr Krzemiński -** -** This program 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 2 of the License, or -** (at your option) any later version. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -*****************************************************************************/ - -#include "qnapicli.h" -#include "libqnapi.h" -#include "subtitlelanguage.h" - -#include - -QNapiCli::QNapiCli(int argc, char **argv, const QNapiConfig &config, - const QString &uiLanguage) - : QCoreApplication(argc, argv), - config(config), - uiLanguage(uiLanguage), - mode(CM_UNSET), - showPolicy(SLP_USE_CONFIG), - langBackupPassed(false) { - args = arguments(); -} - -bool QNapiCli::isCliCall(int argc, char **argv) { - QString p; - -#ifdef Q_OS_WIN - for (int i = 1; i < argc; i++) { - p = argv[i]; - if ((p == "--quiet") || (p == "-q")) return true; - } - return false; -#else - for (int i = 1; i < argc; i++) { - p = argv[i]; - - if (p == "--options") { - return false; - } - - if ((p == "--console") || (p == "-c") || (p == "--quiet") || (p == "-q")) { - return true; - } - - if ((p == "--help") || (p == "-h") || (p == "--help-languages") || - (p == "-hl")) { - return true; - } - } - -#if defined(Q_OS_MAC) - return false; -#elif (defined(Q_OS_UNIX) || defined(Q_OS_LINUX)) - if (getenv("DISPLAY") == 0) return true; - return false; -#else - return false; -#endif -#endif -} - -bool QNapiCli::analyze(const QStringList &args) { - QString p; - - for (int i = 1; i < args.size(); i++) { - p = args[i]; - - if ((p == "--help") || (p == "-h")) { - mode = CM_HELP; - return true; - } else if ((p == "--help-languages") || (p == "-hl")) { - mode = CM_HELP_LANGUAGES; - return true; - } else if ((p == "--console") || (p == "-c")) { - if (mode == CM_UNSET) { -#ifdef Q_OS_WIN - mode = CM_QUIET; - showPolicy = SLP_NEVER_SHOW; -#else - mode = CM_CONSOLE; -#endif - } - } else if ((p == "--quiet") || (p == "-q")) { - mode = CM_QUIET; - showPolicy = SLP_NEVER_SHOW; - } else if ((p == "--lang") || (p == "-l")) { - ++i; - if (i >= args.size()) return false; - p = args[i]; - - lang = SubtitleLanguage(p).toTwoLetter(); - if (lang.isEmpty()) { - printCli(tr("Invalid language code: %1").arg(p)); - return false; - } - } else if ((p == "--lang-backup") || (p == "-lb")) { - ++i; - if (i >= args.size()) return false; - p = args[i]; - - langBackup = SubtitleLanguage(p).toTwoLetter(); - langBackupPassed = true; - } else if ((p == "--format") || (p == "-f")) { - ++i; - if (i >= args.size()) return false; - p = args[i]; - - if (LibQNapi::subtitleFormatsRegistry()->select(p).isNull()) { - printCli(tr("Invalid target subtitles format: %1").arg(p)); - return false; - } - - config = config.setPostProcessingConfig( - config.postProcessingConfig().setSubFormat(p)); - } else if ((p == "--extension") || (p == "-e")) { - ++i; - if (i >= args.size()) return false; - p = args[i]; - - config = config.setPostProcessingConfig( - config.postProcessingConfig().setSubExtension(p)); - } else if ((p == "--show-list") || (p == "-s")) { - if (mode != CM_QUIET) showPolicy = SLP_SHOW; - } else if ((p == "--dont-show-list") || (p == "-d")) { - showPolicy = SLP_NEVER_SHOW; - } else if (QFileInfo(p).isFile()) { - movieList << p; - } - } - - if (config.generalConfig().quietBatch() && !movieList.isEmpty()) { - mode = CM_QUIET; - return true; - } - -#if (defined(Q_OS_UNIX) || defined(Q_OS_LINUX)) - if ((getenv("DISPLAY") == 0) && (mode == CM_UNSET)) mode = CM_CONSOLE; -#endif - - return true; -} - -int QNapiCli::exec() { - QTranslator qnapiTranslator; - qnapiTranslator.load("qnapi_" + uiLanguage, ":/translations"); - installTranslator(&qnapiTranslator); - - if (!analyze(args)) return EC_CMD_LINE_ARG_PARSING_ERROR; - - if (mode == CM_UNSET) return 1; - - if (mode != CM_QUIET) printHeader(); - - if (mode == CM_HELP_LANGUAGES) { - printHelpLanguages(); - return EC_OK; - } - - if ((mode == CM_CONSOLE || mode == CM_QUIET) && (movieList.isEmpty())) { - printCli(tr("File not found!")); - return EC_MOVIE_FILE_NOT_FOUND; - } - - if (mode == CM_HELP) { - printHelp(QFileInfo(args.first()).fileName()); - return EC_OK; - } - - QNapi napi(config); - - if (!napi.checkP7ZipPath()) { - printCli( - tr("Path to the program p7zip is incorrect! Check your settings.")); - return EC_P7ZIP_UNAVAILABLE; - } - - if (!napi.checkTmpPath()) { - printCli( - tr("Can not write to the temporary directory! Check your settings.")); - return EC_CANNOT_WRITE_TMP_DIR; - } - - if (lang.isEmpty()) lang = config.generalConfig().language(); - - if (!langBackupPassed) langBackup = config.generalConfig().backupLanguage(); - - foreach (QString movie, movieList) { - printCli(tr(" * Downloading subtitles for '%1'") - .arg(QFileInfo(movie).fileName())); - - napi.setMoviePath(movie); - - if (!napi.checkWritePermissions()) { - printCli(tr(" No permission to write to the directory '%1'!") - .arg(QFileInfo(movie).path())); - return EC_NO_WRITE_PERMISSIONS; - } - - napi.clearSubtitlesList(); - - printCli(tr(" Calculating checksums...")); - napi.checksum(); - - bool found = false; - SearchPolicy sp = config.generalConfig().searchPolicy(); - - if (sp == SP_SEARCH_ALL_WITH_BACKUP_LANG) { - foreach (QString e, napi.listLoadedEngines()) { - printCli(tr(" Searching for subtitles [%1] (%2)...").arg(lang, e)); - found = napi.lookForSubtitles(lang, e) || found; - printCli(tr(" Searching for subtitles in alternative language [%1] " - "(%2)...") - .arg(langBackup, e)); - found = napi.lookForSubtitles(langBackup, e) || found; - } - } else { - foreach (QString e, napi.listLoadedEngines()) { - printCli(tr(" Searching for subtitles [%1] (%2)...").arg(lang, e)); - found = napi.lookForSubtitles(lang, e) || found; - - if (sp == SP_BREAK_IF_FOUND && found) break; - } - - if (!found && !langBackup.isEmpty()) { - foreach (QString e, napi.listLoadedEngines()) { - printCli(tr(" Searching for subtitles in alternative language [%1] " - "(%2)...") - .arg(langBackup, e)); - found = napi.lookForSubtitles(langBackup, e) || found; - - if (sp == SP_BREAK_IF_FOUND && found) break; - } - } - } - - if (!found) { - printCli(tr(" Subtitles not found!")); - return EC_SUBTITLES_NOT_FOUND; - } - - int selIdx = 0; - - bool showList = false; - bool napiShowList = napi.needToShowList(); - - if ((mode != CM_QUIET) && (showPolicy != SLP_NEVER_SHOW)) - showList = napiShowList; - else if (showPolicy == SLP_SHOW) - showList = true; - - // jesli mozna i potrzeba, listujemy dostepne napisy - if (showList) { - bool ok = false; - - printCli(tr(" 0)\tDo not download subtitles for this video")); - printCli(tr(" Found subtitles:")); - - int i = 1; - - QList list = napi.listSubtitles(); - - foreach (SubtitleInfo s, list) { - QString resolution = ""; - - if (s.resolution == SUBTITLE_GOOD) - resolution = tr(" (good)"); - else if (s.resolution == SUBTITLE_BAD) - resolution = tr(" (bad)"); - - printCli(QString(" %1)\t%2 (%3) (%4) (%5)%6") - .arg(i++) - .arg(s.name) - .arg(s.format) - .arg(s.lang) - .arg(s.engine) - .arg(resolution)); - } - - while (!ok) { - std::cout << tr(" Select subtitles to download: ").toStdString(); - char line[8]; - std::cin.getline(line, 8); - - selIdx = QString(line).toInt(&ok); - - if (!ok) { - printCli(tr(" You must enter a number!")); - std::cin.clear(); - } else if ((selIdx > list.size()) || (selIdx < 0)) { - ok = false; - printCli(tr(" Enter a number from the list!")); - } - } - - --selIdx; - } else { - selIdx = napi.bestIdx(); - } - - if (selIdx == -1) continue; - - printCli(tr(" Downloading subtitles...")); - if (!napi.download(selIdx)) { - printCli(tr(" Unable to download subtitles!")); - return EC_COULD_NOT_DOWNLOAD; - } - - printCli(tr(" Unpacking subtitles...")); - if (!napi.unpack(selIdx)) { - printCli(tr(" Failed to unpack subtitles!")); - return EC_COULD_NOT_UNARCHIVE; - } - - if (napi.ppEnabled()) { - printCli(tr(" Post-processing subtitles file...")); - napi.postProcessSubtitles(); - } - - printCli(tr(" Adjusting subtitles...")); - if (!napi.matchSubtitles()) { - printCli(tr(" Could not adjust subtitles!")); - return EC_COULD_NOT_MATCH; - } - - napi.cleanup(); - } - - return EC_OK; -} - -void QNapiCli::printHeader() { - printCli(tr("QNapi %1, %2") - .arg(LibQNapi::displayableVersion()) - .arg(LibQNapi::webpageUrl())); - printCli(tr("Qt version: %1").arg(qVersion())); - printCli(); -} - -void QNapiCli::printHelp(const QString &binaryFileName) { - QString formats = - LibQNapi::subtitleFormatsRegistry()->listFormatNames().join(","); - - printCli(tr("QNapi is distributed under the GNU General Public License v2.")); - printCli(); - printCli(tr("Syntax: %1 [options] [list of files]").arg(binaryFileName)); - printCli(tr("Available options:")); - printCli(tr(" -c, --console Download subtitles with console")); - printCli( - tr(" -q, --quiet Download subtitles quietly without " - "showing")); - printCli( - tr(" any messages or windows (implies -d)")); - printCli(); - printCli( - tr(" -s, --show-list Show a list of subtitles (works only " - "with -c)")); - printCli( - tr(" -d, --dont-show-list Do not show a list of subtitles (works " - "only with -c)")); - printCli(); - printCli(tr(" -l, --lang [code] Preferred subtitles language")); - printCli(tr(" -lb,--lang-backup [code] Alternative subtitles language")); - printCli(tr(" -f, --format [format] Select target subtitles file " - "format (%1)") - .arg(formats)); - printCli(tr( - " -e, --extension [ext] Select target subtitles file extension")); - printCli(); - printCli(tr(" -o, --options Show program options (only GUI)")); - printCli(tr(" -h, --help Show help text")); - printCli(tr( - " -hl,--help-languages List of available subtitles languages")); - printCli(); -} - -void QNapiCli::printHelpLanguages() { - printCli( - tr("List of languages recognized by QNapi, including corresponding")); - printCli(tr("two-letter language codes:")); - printCli(); - - SubtitleLanguage L, LB; - QStringList langs = L.listLanguages(); - - foreach (QString lang, langs) { - L.setLanguage(lang); - printCli(QString(" %1 - %2").arg(L.toTwoLetter()).arg(lang)); - } - - L.setLanguage(config.generalConfig().language()); - LB.setLanguage(config.generalConfig().backupLanguage()); - - printCli(); - printCli(tr("Current default subtitles language: %1 (%2)") - .arg(L.toFullName()) - .arg(L.toTwoLetter())); - - if (LB.toFullName().isEmpty()) { - printCli(tr("No alternative subtitles language has been set")); - } else { - printCli(tr("Current alternative subtitles language: %1 (%2)") - .arg(LB.toFullName()) - .arg(LB.toTwoLetter())); - } -} - -void QNapiCli::printCli(const QString &string) { - if (mode != CM_QUIET) std::cout << string.toStdString() << std::endl; -} diff --git a/gui/src/qnapicli.h b/gui/src/qnapicli.h deleted file mode 100644 index a1b0edd..0000000 --- a/gui/src/qnapicli.h +++ /dev/null @@ -1,76 +0,0 @@ -/***************************************************************************** -** QNapi -** Copyright (C) 2008-2017 Piotr Krzemiński -** -** This program 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 2 of the License, or -** (at your option) any later version. -** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -** -*****************************************************************************/ - -#ifndef __QNAPICLI__H__ -#define __QNAPICLI__H__ - -#include "config/qnapiconfig.h" - -#include -#include -#include -#include -#include -#include "qnapi.h" - -class QNapiCli : public QCoreApplication { - Q_OBJECT - - public: - QNapiCli(int argc, char **argv, const QNapiConfig &config, - const QString &uiLanguage); - - static bool isCliCall(int argc, char **argv); - int exec(); - - private: - QStringList movieList; - QNapiConfig config; - const QString uiLanguage; - - enum CliExitCode { - EC_CMD_LINE_ARG_PARSING_ERROR = -1, - EC_OK = 0, - EC_NON_CLI_MODE = 1, - EC_P7ZIP_UNAVAILABLE = 2, - EC_CANNOT_WRITE_TMP_DIR = 3, - EC_UNSUPPORTED_ENGINE = 4, - EC_NO_WRITE_PERMISSIONS = 5, - EC_SUBTITLES_NOT_FOUND = 6, - EC_COULD_NOT_DOWNLOAD = 7, - EC_COULD_NOT_UNARCHIVE = 8, - EC_COULD_NOT_MATCH = 9, - EC_MOVIE_FILE_NOT_FOUND = 10 - }; - - enum CliMode { CM_UNSET, CM_HELP, CM_HELP_LANGUAGES, CM_CONSOLE, CM_QUIET }; - - enum ShowListPolicy { SLP_SHOW, SLP_USE_CONFIG, SLP_NEVER_SHOW }; - - CliMode mode; - ShowListPolicy showPolicy; - - QString lang; - QString langBackup; - bool langBackupPassed; - QStringList args; - - bool analyze(const QStringList &args); - void printHeader(); - void printHelp(const QString &binaryFileName); - void printHelpLanguages(); - void printCli(const QString &string = ""); -}; - -#endif diff --git a/gui/ui/frmabout.ui b/gui/ui/frmabout.ui index fee0338..3cf4110 100644 --- a/gui/ui/frmabout.ui +++ b/gui/ui/frmabout.ui @@ -24,33 +24,23 @@ :/icon/qnapi.png:/icon/qnapi.png - - - - Qt::Horizontal - - + + + - 226 - 20 + 0 + 44 - - - - - - Qt::Horizontal + + QDialogButtonBox::Close - - - 217 - 20 - + + true - + - + Qt::ScrollBarAsNeeded @@ -63,8 +53,8 @@ 0 0 - 614 - 334 + 606 + 358 @@ -194,14 +184,7 @@ - - - - Close - - - - + 0 @@ -247,22 +230,6 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 358 - 20 - - - - @@ -270,18 +237,34 @@ - pbClose - clicked() + bbAbout + accepted() + frmAbout + accept() + + + 334 + 476 + + + 636 + 12 + + + + + bbAbout + rejected() frmAbout - close() + reject() - 298 - 352 + 302 + 481 - 288 - 187 + 636 + 40 diff --git a/libqnapi/libqnapi.pro b/libqnapi/libqnapi.pro index bd0c51c..c939b1b 100644 --- a/libqnapi/libqnapi.pro +++ b/libqnapi/libqnapi.pro @@ -47,10 +47,28 @@ SOURCES += src/config/configreader.cpp \ src/subtitlelanguage.cpp \ src/subtitlematcher.cpp \ src/subtitlepostprocessor.cpp \ + src/utils/console.cpp \ src/utils/encodingutils.cpp \ src/utils/p7zipdecoder.cpp \ src/utils/synchttp.cpp \ - src/utils/syncxmlrpc.cpp + src/utils/syncxmlrpc.cpp \ + src/qnapi.cpp \ + src/parser/cliargparser.cpp \ + src/parser/cliargparsersexecutor.cpp \ + src/parser/showhelpargparser.cpp \ + src/parser/showhelplanguagesargparser.cpp \ + src/parser/quietbatchargparser.cpp \ + src/parser/showlistargparser.cpp \ + src/parser/dontshowlistargparser.cpp \ + src/parser/langargparser.cpp \ + src/parser/backuplangargparser.cpp \ + src/parser/formatargparser.cpp \ + src/parser/extensionargparser.cpp \ + src/parser/downloadsubtitlesargparser.cpp \ + src/parser/showoptionsargparser.cpp \ + src/parser/runcliappargparser.cpp \ + src/parser/scandirectoryargparser.cpp \ + src/utils/helphelper.cpp HEADERS += src/config/configreader.h \ @@ -83,11 +101,31 @@ HEADERS += src/config/configreader.h \ src/subtitlelanguage.h \ src/subtitlematcher.h \ src/subtitlepostprocessor.h \ + src/utils/console.h \ src/utils/encodingutils.h \ src/utils/p7zipdecoder.h \ src/utils/synchttp.h \ src/utils/syncxmlrpc.h \ - src/version.h + src/version.h \ + src/qnapi.h \ + src/tr.h \ + src/parser/cliargparser.h \ + src/parser/cliargparsersexecutor.h \ + src/qnapicommand.h \ + src/parser/showhelpargparser.h \ + src/parser/showhelplanguagesargparser.h \ + src/parser/quietbatchargparser.h \ + src/parser/showlistargparser.h \ + src/parser/dontshowlistargparser.h \ + src/parser/langargparser.h \ + src/parser/backuplangargparser.h \ + src/parser/formatargparser.h \ + src/parser/extensionargparser.h \ + src/parser/downloadsubtitlesargparser.h \ + src/parser/showoptionsargparser.h \ + src/parser/runcliappargparser.h \ + src/parser/scandirectoryargparser.h \ + src/utils/helphelper.h unix:!macx { PKGCONFIG += libmediainfo @@ -95,8 +133,8 @@ unix:!macx { macx { INCLUDEPATH += ../deps/libmediainfo/include - QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.7 - QMAKE_CXXFLAGS_X86_64 = -mmacosx-version-min=10.7 + QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.8 + QMAKE_CXXFLAGS_X86_64 = -mmacosx-version-min=10.8 } win32 { diff --git a/libqnapi/src/config/configreader.cpp b/libqnapi/src/config/configreader.cpp index 3fb098c..b31a290 100644 --- a/libqnapi/src/config/configreader.cpp +++ b/libqnapi/src/config/configreader.cpp @@ -167,12 +167,10 @@ const GeneralConfig ConfigReader::resolveP7zipPath( } else { QString p7zipPath = ""; -#if defined(Q_OS_MAC) - p7zipPath = - QFileInfo(appExecutableDir + "/../Resources/7za").absoluteFilePath(); -#elif defined(Q_OS_WIN) +#ifdef Q_OS_WIN p7zipPath = QFileInfo(appExecutableDir + "/7za.exe").absoluteFilePath(); #else + QString pathEnv = QProcess::systemEnvironment().filter(QRegExp("^PATH=(.*)$")).value(0); QStringList sysPaths = pathEnv.mid(5).split(":"); @@ -187,6 +185,10 @@ const GeneralConfig ConfigReader::resolveP7zipPath( sysPaths << appExecutableDir; +#ifdef Q_OS_MAC + sysPaths << QFileInfo(appExecutableDir + "/../Resources/").absolutePath(); +#endif + QStringList p7zipBinaries = {"7z", "7za"}; foreach (const QString sysPath, sysPaths) { diff --git a/libqnapi/src/config/generalconfig.h b/libqnapi/src/config/generalconfig.h index 60c78ea..9678133 100644 --- a/libqnapi/src/config/generalconfig.h +++ b/libqnapi/src/config/generalconfig.h @@ -44,6 +44,7 @@ class GeneralConfig { QString changePermissionsTo_; public: + GeneralConfig() {} GeneralConfig(const QString& uiLanguage, const QString& p7zipPath, const QString& tmpPath, const QString& language, const QString& backupLanguage, const bool& noBackup, diff --git a/libqnapi/src/config/postprocessingconfig.h b/libqnapi/src/config/postprocessingconfig.h index 9d394a9..ec6aaac 100644 --- a/libqnapi/src/config/postprocessingconfig.h +++ b/libqnapi/src/config/postprocessingconfig.h @@ -39,6 +39,7 @@ class PostProcessingConfig { QStringList removeLinesWords_; public: + PostProcessingConfig() {} PostProcessingConfig(const bool& enabled, const EncodingChangeMethod& encodingChangeMethod, const QString& encodingFrom, diff --git a/libqnapi/src/config/qnapiconfig.h b/libqnapi/src/config/qnapiconfig.h index d9ec000..60e2c9a 100644 --- a/libqnapi/src/config/qnapiconfig.h +++ b/libqnapi/src/config/qnapiconfig.h @@ -34,6 +34,7 @@ class QNapiConfig { QString lastOpenedDir_; public: + QNapiConfig(){}; QNapiConfig(const bool& firstrun, const QString& version, const GeneralConfig& generalConfig, const QList>& enabledEngines, diff --git a/libqnapi/src/config/scanconfig.h b/libqnapi/src/config/scanconfig.h index 18bb7f4..89120f1 100644 --- a/libqnapi/src/config/scanconfig.h +++ b/libqnapi/src/config/scanconfig.h @@ -26,6 +26,7 @@ class ScanConfig { QString skipFilters_; public: + ScanConfig() {} ScanConfig(const QString& lastDir, const bool& skipIfSubtitlesExist, const QStringList& filters, const QString& skipFilters) : lastDir_(lastDir), diff --git a/libqnapi/src/engines/subtitledownloadengine.cpp b/libqnapi/src/engines/subtitledownloadengine.cpp index 01dc44b..c9d98d6 100644 --- a/libqnapi/src/engines/subtitledownloadengine.cpp +++ b/libqnapi/src/engines/subtitledownloadengine.cpp @@ -15,10 +15,13 @@ #include "engines/subtitledownloadengine.h" #include #include +#include #include "subconvert/subtitleformatsregistry.h" SubtitleDownloadEngine::SubtitleDownloadEngine(const QString& tmpPath) - : tmpPath(tmpPath) {} + : tmpPath(tmpPath) { + QLoggingCategory::setFilterRules("qt.network.ssl.warning=false"); +} void SubtitleDownloadEngine::setMoviePath(const QString& path) { movie = path; } diff --git a/libqnapi/src/parser/backuplangargparser.cpp b/libqnapi/src/parser/backuplangargparser.cpp new file mode 100644 index 0000000..8ea0a90 --- /dev/null +++ b/libqnapi/src/parser/backuplangargparser.cpp @@ -0,0 +1,52 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "backuplangargparser.h" +#include "subtitlelanguage.h" + +BackupLangArgParser::BackupLangArgParser() {} + +QVariant BackupLangArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + int idx = args.indexOf("-lb"); + if (idx == -1) { + idx = args.indexOf("--lang-backup"); + } + if (idx == -1) { + return QVariant::fromValue(NothingParsed()); + } + + if (idx == args.size() - 1) { + return QVariant::fromValue( + ParseError{tr("You need to pass backup language code after %1 argument") + .arg(args[idx])}); + } + + QString nextArg = args[idx + 1]; + SubtitleLanguage sl(nextArg); + QString twoLetterLang = sl.toTwoLetter(); + + if (twoLetterLang.isEmpty()) { + return QVariant::fromValue( + ParseError{tr("Invalid backup language code passed: %1").arg(nextArg)}); + } else { + return QVariant::fromValue(ParsedModifier{config.setGeneralConfig( + config.generalConfig().setBackupLanguage(twoLetterLang))}); + } +} + +Maybe BackupLangArgParser::helpInfo() const { + return just(HelpInfo{"-lb", "--lang-backup", tr("code"), + tr("Alternative subtitles language")}); +} diff --git a/libqnapi/src/parser/backuplangargparser.h b/libqnapi/src/parser/backuplangargparser.h new file mode 100644 index 0000000..3935414 --- /dev/null +++ b/libqnapi/src/parser/backuplangargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef BACKUPLANGARGPARSER_H +#define BACKUPLANGARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class BackupLangArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(BackupLangArgParser) + + public: + BackupLangArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // BACKUPLANGARGPARSER_H diff --git a/libqnapi/src/parser/cliargparser.cpp b/libqnapi/src/parser/cliargparser.cpp new file mode 100644 index 0000000..5c08b1d --- /dev/null +++ b/libqnapi/src/parser/cliargparser.cpp @@ -0,0 +1,22 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef CLIARGPARSER_CPP +#define CLIARGPARSER_CPP + +#include "parser/cliargparser.h" + +CliArgParser::~CliArgParser() {} + +#endif // CLIARGPARSER_CPP diff --git a/libqnapi/src/parser/cliargparser.h b/libqnapi/src/parser/cliargparser.h new file mode 100644 index 0000000..03b7adf --- /dev/null +++ b/libqnapi/src/parser/cliargparser.h @@ -0,0 +1,65 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef CLIARGPARSER_H +#define CLIARGPARSER_H + +#include "config/qnapiconfig.h" + +#include +#include +#include "Either.h" +#include "Maybe.h" + +class CliArgParser { + public: + struct ParseError { + QString errorMessage; + }; + + struct NothingParsed {}; + + struct ParsedModifier { + const QNapiConfig refinedConfig; + }; + + struct ParsedCommand { + const QNapiConfig refinedConfig; + QVariant command; + }; + + struct HelpInfo { + QString shortSwitch; + QString longSwitch; + QString argName; + QString description; + }; + + virtual ~CliArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const = 0; + + virtual Maybe helpInfo() const { return nothing(); } +}; + +Q_DECLARE_METATYPE(CliArgParser::ParseError) +Q_DECLARE_METATYPE(CliArgParser::NothingParsed) +Q_DECLARE_METATYPE(CliArgParser::ParsedModifier) +Q_DECLARE_METATYPE(CliArgParser::ParsedCommand) +Q_DECLARE_METATYPE(Maybe) +Q_DECLARE_METATYPE(CliArgParser::HelpInfo) +Q_DECLARE_METATYPE(Maybe) + +#endif // CLIARGPARSER_H diff --git a/libqnapi/src/parser/cliargparsersexecutor.cpp b/libqnapi/src/parser/cliargparsersexecutor.cpp new file mode 100644 index 0000000..f2be1f0 --- /dev/null +++ b/libqnapi/src/parser/cliargparsersexecutor.cpp @@ -0,0 +1,89 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "cliargparsersexecutor.h" + +namespace CliArgParsersExecutor { + +Either> executeParsers( + const QList> &parsers, const QStringList &args, + const QNapiConfig &config) { + QNapiConfig refinedConfig = config; + + foreach (auto cliArgParser, parsers) { + auto result = cliArgParser->parse(args, refinedConfig); + + if (result.canConvert()) { + return some(result.value().errorMessage); + } else if (result.canConvert()) { + Maybe maybeParsedCommand = + just(result.value()); + return some(maybeParsedCommand); + } else if (result.canConvert()) { + refinedConfig = + result.value().refinedConfig; + } + } + + Maybe n = nothing(); + return some(n); +} + +QStringList formatHelpLines(const QList> &parsers, + int switchesBlockSize, int descBlockSize, + int preSwitchSpaceSize) { + QString preSwitchSpace(preSwitchSpaceSize, ' '); + QStringList helpLines; + + foreach (auto parser, parsers) { + auto maybeHelpInfo = parser->helpInfo(); + + if (maybeHelpInfo) { + auto helpInfo = maybeHelpInfo.value(); + + QString optSwitches = preSwitchSpace + helpInfo.shortSwitch + ","; + if (helpInfo.shortSwitch.size() == 2) optSwitches += " "; + optSwitches += helpInfo.longSwitch; + if (!helpInfo.argName.isEmpty()) { + optSwitches += QString(" [%1]").arg(helpInfo.argName); + } + if (optSwitches.length() < switchesBlockSize) { + optSwitches += QString(switchesBlockSize - optSwitches.length(), ' '); + } + + QString notConsumedDescription = helpInfo.description.trimmed(); + while (!notConsumedDescription.isEmpty()) { + QString helpPart; + + if (notConsumedDescription.size() <= descBlockSize) { + helpPart = notConsumedDescription; + notConsumedDescription = ""; + } else { + int lastSpace = + notConsumedDescription.left(1 + descBlockSize).lastIndexOf(' '); + helpPart = notConsumedDescription.left(lastSpace); + notConsumedDescription = + notConsumedDescription.mid(lastSpace).trimmed(); + } + + helpLines << optSwitches + helpPart; + optSwitches = QString(switchesBlockSize, ' '); + } + } + } + + return helpLines; +} + +} // namespace CliArgParsersExecutor diff --git a/libqnapi/src/parser/cliargparsersexecutor.h b/libqnapi/src/parser/cliargparsersexecutor.h new file mode 100644 index 0000000..4f42317 --- /dev/null +++ b/libqnapi/src/parser/cliargparsersexecutor.h @@ -0,0 +1,43 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef CLIARGPARSERSEXECUTOR_H +#define CLIARGPARSERSEXECUTOR_H + +#include "config/qnapiconfig.h" +#include "parser/cliargparser.h" +#include "tr.h" + +#include +#include +#include +#include +#include "Either.h" +#include "Maybe.h" + +namespace CliArgParsersExecutor { + +Q_DECLARE_NAMESPACE_TR(CliArgParsersExecutor) + +Either> executeParsers( + const QList> &parsers, const QStringList &args, + const QNapiConfig &config); + +QStringList formatHelpLines(const QList> &parsers, + int switchesBlockSize, int descBlockSize, + int preSwitchSpaceSize); + +} // namespace CliArgParsersExecutor + +#endif // CLIARGPARSERSEXECUTOR_H diff --git a/libqnapi/src/parser/dontshowlistargparser.cpp b/libqnapi/src/parser/dontshowlistargparser.cpp new file mode 100644 index 0000000..b6dfb09 --- /dev/null +++ b/libqnapi/src/parser/dontshowlistargparser.cpp @@ -0,0 +1,33 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "dontshowlistargparser.h" + +DontShowListArgParser::DontShowListArgParser() {} + +QVariant DontShowListArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + if (args.contains("-d") || args.contains("--dont-show-list")) { + return QVariant::fromValue(ParsedModifier{ + config.setGeneralConfig(config.generalConfig().setDownloadPolicy( + DownloadPolicy::DP_NEVER_SHOW_LIST))}); + } else { + return QVariant::fromValue(NothingParsed()); + } +} + +Maybe DontShowListArgParser::helpInfo() const { + return just(HelpInfo{"-d", "--dont-show-list", "", + tr("Never show a list of available subtitles")}); +} diff --git a/libqnapi/src/parser/dontshowlistargparser.h b/libqnapi/src/parser/dontshowlistargparser.h new file mode 100644 index 0000000..eb69867 --- /dev/null +++ b/libqnapi/src/parser/dontshowlistargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef DONTSHOWLISTARGPARSER_H +#define DONTSHOWLISTARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class DontShowListArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(DontShowListArgParser) + + public: + DontShowListArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // DONTSHOWLISTARGPARSER_H diff --git a/libqnapi/src/parser/downloadsubtitlesargparser.cpp b/libqnapi/src/parser/downloadsubtitlesargparser.cpp new file mode 100644 index 0000000..8741f86 --- /dev/null +++ b/libqnapi/src/parser/downloadsubtitlesargparser.cpp @@ -0,0 +1,48 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "downloadsubtitlesargparser.h" +#include "qnapicommand.h" + +#include + +DownloadSubtitlesArgParser::DownloadSubtitlesArgParser() {} + +QVariant DownloadSubtitlesArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + QStringList filePaths; + + foreach (QString arg, args) { + if (QFileInfo(arg).isFile()) { + filePaths << arg; + continue; + } + + if (arg.startsWith("file://")) { + arg.remove(0, 7); + if (QFileInfo(arg).isFile()) { + filePaths << arg; + continue; + } + } + } + + if (filePaths.isEmpty()) { + return QVariant::fromValue(NothingParsed()); + } else { + return QVariant::fromValue(ParsedCommand{ + config, + QVariant::fromValue(QNapiCommand::DownloadSubtitles{filePaths})}); + } +} diff --git a/libqnapi/src/parser/downloadsubtitlesargparser.h b/libqnapi/src/parser/downloadsubtitlesargparser.h new file mode 100644 index 0000000..d8e471e --- /dev/null +++ b/libqnapi/src/parser/downloadsubtitlesargparser.h @@ -0,0 +1,28 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef DOWNLOADSUBTITLESARGPARSER_H +#define DOWNLOADSUBTITLESARGPARSER_H + +#include "parser/cliargparser.h" + +class DownloadSubtitlesArgParser : public CliArgParser { + public: + DownloadSubtitlesArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; +}; + +#endif // DOWNLOADSUBTITLESARGPARSER_H diff --git a/libqnapi/src/parser/extensionargparser.cpp b/libqnapi/src/parser/extensionargparser.cpp new file mode 100644 index 0000000..4e9b5ec --- /dev/null +++ b/libqnapi/src/parser/extensionargparser.cpp @@ -0,0 +1,50 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "extensionargparser.h" +#include + +ExtensionArgParser::ExtensionArgParser() {} + +QVariant ExtensionArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + int idx = args.indexOf("-e"); + if (idx == -1) { + idx = args.indexOf("--extension"); + } + if (idx == -1) { + return QVariant::fromValue(NothingParsed()); + } + + if (idx == args.size() - 1) { + return QVariant::fromValue( + ParseError{tr("You need to pass subtitles extension after %1 argument") + .arg(args[idx])}); + } + + QString ext = args[idx + 1]; + + if (!QRegExp("^[A-Za-z0-9]+$").exactMatch(ext)) { + return QVariant::fromValue(ParseError{ + tr("Invalid target subtitles extension passed: %1").arg(ext)}); + } else { + return QVariant::fromValue(ParsedModifier{config.setPostProcessingConfig( + config.postProcessingConfig().setSubExtension(ext))}); + } +} + +Maybe ExtensionArgParser::helpInfo() const { + return just(HelpInfo{"-e", "--extension", tr("ext"), + tr("Select target subtitles file extension")}); +} diff --git a/libqnapi/src/parser/extensionargparser.h b/libqnapi/src/parser/extensionargparser.h new file mode 100644 index 0000000..253ee28 --- /dev/null +++ b/libqnapi/src/parser/extensionargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef EXTENSIONARGPARSER_H +#define EXTENSIONARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class ExtensionArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(ExtensionArgParser) + + public: + ExtensionArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // EXTENSIONARGPARSER_H diff --git a/libqnapi/src/parser/formatargparser.cpp b/libqnapi/src/parser/formatargparser.cpp new file mode 100644 index 0000000..e2ce066 --- /dev/null +++ b/libqnapi/src/parser/formatargparser.cpp @@ -0,0 +1,51 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "formatargparser.h" +#include "libqnapi.h" + +FormatArgParser::FormatArgParser() {} + +QVariant FormatArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + int idx = args.indexOf("-f"); + if (idx == -1) { + idx = args.indexOf("--format"); + } + if (idx == -1) { + return QVariant::fromValue(NothingParsed()); + } + + if (idx == args.size() - 1) { + return QVariant::fromValue(ParseError{ + tr("You need to pass subtitles format code after %1 argument") + .arg(args[idx])}); + } + + QString format = args[idx + 1]; + + if (LibQNapi::subtitleFormatsRegistry()->select(format).isNull()) { + return QVariant::fromValue(ParseError{ + tr("Invalid target subtitles format passed: %1").arg(format)}); + } else { + return QVariant::fromValue(ParsedModifier{config.setPostProcessingConfig( + config.postProcessingConfig().setSubFormat(format))}); + } +} + +Maybe FormatArgParser::helpInfo() const { + return just(HelpInfo{ + "-f", "--format", tr("format"), + tr("Select target subtitles file format (one of mDVD, MPL2, SRT, TMP)")}); +} diff --git a/libqnapi/src/parser/formatargparser.h b/libqnapi/src/parser/formatargparser.h new file mode 100644 index 0000000..05bd4f6 --- /dev/null +++ b/libqnapi/src/parser/formatargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef FORMATARGPARSER_H +#define FORMATARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class FormatArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(FormatArgParser) + + public: + FormatArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // FORMATARGPARSER_H diff --git a/libqnapi/src/parser/langargparser.cpp b/libqnapi/src/parser/langargparser.cpp new file mode 100644 index 0000000..78e44d2 --- /dev/null +++ b/libqnapi/src/parser/langargparser.cpp @@ -0,0 +1,51 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "langargparser.h" +#include "subtitlelanguage.h" + +LangArgParser::LangArgParser() {} + +QVariant LangArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + int idx = args.indexOf("-l"); + if (idx == -1) { + idx = args.indexOf("--lang"); + } + if (idx == -1) { + return QVariant::fromValue(NothingParsed()); + } + + if (idx == args.size() - 1) { + return QVariant::fromValue(ParseError{ + tr("You need to pass language code after %1 argument").arg(args[idx])}); + } + + QString nextArg = args[idx + 1]; + SubtitleLanguage sl(nextArg); + QString twoLetterLang = sl.toTwoLetter(); + + if (twoLetterLang.isEmpty()) { + return QVariant::fromValue( + ParseError{tr("Invalid language code passed: %1").arg(nextArg)}); + } else { + return QVariant::fromValue(ParsedModifier{config.setGeneralConfig( + config.generalConfig().setLanguage(twoLetterLang))}); + } +} + +Maybe LangArgParser::helpInfo() const { + return just( + HelpInfo{"-l", "--lang", tr("code"), tr("Preferred subtitles language")}); +} diff --git a/libqnapi/src/parser/langargparser.h b/libqnapi/src/parser/langargparser.h new file mode 100644 index 0000000..f3a00a7 --- /dev/null +++ b/libqnapi/src/parser/langargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef LANGARGPARSER_H +#define LANGARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class LangArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(LangArgParser) + + public: + LangArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // LANGARGPARSER_H diff --git a/libqnapi/src/parser/quietbatchargparser.cpp b/libqnapi/src/parser/quietbatchargparser.cpp new file mode 100644 index 0000000..9260a02 --- /dev/null +++ b/libqnapi/src/parser/quietbatchargparser.cpp @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "quietbatchargparser.h" +#include "qnapicommand.h" + +QuietBatchArgParser::QuietBatchArgParser() {} + +QVariant QuietBatchArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + if (args.contains("-q") || args.contains("--quiet")) { + return QVariant::fromValue(ParsedModifier{ + config.setGeneralConfig(config.generalConfig().setQuietBatch(true))}); + } else { + return QVariant::fromValue(NothingParsed()); + } +} + +Maybe QuietBatchArgParser::helpInfo() const { + return just( + HelpInfo{"-q", "--quiet", "", + tr("Download subtitles silently without showing any messages")}); +} diff --git a/libqnapi/src/parser/quietbatchargparser.h b/libqnapi/src/parser/quietbatchargparser.h new file mode 100644 index 0000000..f70fea8 --- /dev/null +++ b/libqnapi/src/parser/quietbatchargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef QUIETBATCHARGPARSER_H +#define QUIETBATCHARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class QuietBatchArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(QuietBatchArgParser) + + public: + QuietBatchArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // QUIETBATCHARGPARSER_H diff --git a/libqnapi/src/parser/runcliappargparser.cpp b/libqnapi/src/parser/runcliappargparser.cpp new file mode 100644 index 0000000..289c1a4 --- /dev/null +++ b/libqnapi/src/parser/runcliappargparser.cpp @@ -0,0 +1,38 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "runcliappargparser.h" +#include "qnapicommand.h" + +RunCLIAppArgParser::RunCLIAppArgParser() {} + +QVariant RunCLIAppArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + if (args.contains("-c") || args.contains("--console")) { + QStringList argsRemovedCLISwitch = args; + argsRemovedCLISwitch.removeAll("-c"); + argsRemovedCLISwitch.removeAll("--console"); + return QVariant::fromValue(ParsedCommand{ + config, + QVariant::fromValue(QNapiCommand::RunCLIApp{argsRemovedCLISwitch})}); + } else { + return QVariant::fromValue(NothingParsed()); + } +} + +Maybe RunCLIAppArgParser::helpInfo() const { + return just( + HelpInfo{"-c", "--console", "", + tr("Run in command-line mode (requires separate CLI binary)")}); +} diff --git a/libqnapi/src/parser/runcliappargparser.h b/libqnapi/src/parser/runcliappargparser.h new file mode 100644 index 0000000..31206f7 --- /dev/null +++ b/libqnapi/src/parser/runcliappargparser.h @@ -0,0 +1,33 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef RUNCLIAPPARGPARSER_H +#define RUNCLIAPPARGPARSER_H + +#include "parser/cliargparser.h" +#include "tr.h" + +class RunCLIAppArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(RunCLIAppArgParser) + + public: + RunCLIAppArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // RUNCLIAPPARGPARSER_H diff --git a/libqnapi/src/parser/scandirectoryargparser.cpp b/libqnapi/src/parser/scandirectoryargparser.cpp new file mode 100644 index 0000000..4b1a744 --- /dev/null +++ b/libqnapi/src/parser/scandirectoryargparser.cpp @@ -0,0 +1,32 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "scandirectoryargparser.h" +#include "qnapicommand.h" + +#include + +ScanDirectoryArgParser::ScanDirectoryArgParser() {} + +QVariant ScanDirectoryArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + foreach (QString arg, args) { + if (QFileInfo(arg).isDir()) { + return QVariant::fromValue(ParsedCommand{ + config, QVariant::fromValue(QNapiCommand::ScanDirectory{arg})}); + } + } + + return QVariant::fromValue(NothingParsed()); +} diff --git a/libqnapi/src/parser/scandirectoryargparser.h b/libqnapi/src/parser/scandirectoryargparser.h new file mode 100644 index 0000000..628a699 --- /dev/null +++ b/libqnapi/src/parser/scandirectoryargparser.h @@ -0,0 +1,28 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef SCANDIRECTORIESARGPARSER_H +#define SCANDIRECTORIESARGPARSER_H + +#include "parser/cliargparser.h" + +class ScanDirectoryArgParser : public CliArgParser { + public: + ScanDirectoryArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; +}; + +#endif // SCANDIRECTORIESARGPARSER_H diff --git a/libqnapi/src/parser/showhelpargparser.cpp b/libqnapi/src/parser/showhelpargparser.cpp new file mode 100644 index 0000000..26ffcb0 --- /dev/null +++ b/libqnapi/src/parser/showhelpargparser.cpp @@ -0,0 +1,32 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "showhelpargparser.h" +#include "qnapicommand.h" + +ShowHelpArgParser::ShowHelpArgParser() {} + +QVariant ShowHelpArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + if (args.contains("-h") || args.contains("--help")) { + return QVariant::fromValue( + ParsedCommand{config, QVariant::fromValue(QNapiCommand::ShowHelp())}); + } else { + return QVariant::fromValue(NothingParsed()); + } +} + +Maybe ShowHelpArgParser::helpInfo() const { + return just(HelpInfo{"-h", "--help", "", tr("Show help text")}); +} diff --git a/libqnapi/src/parser/showhelpargparser.h b/libqnapi/src/parser/showhelpargparser.h new file mode 100644 index 0000000..87a6059 --- /dev/null +++ b/libqnapi/src/parser/showhelpargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef SHOWHELPARGPARSER_H +#define SHOWHELPARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class ShowHelpArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(ShowHelpArgParser) + + public: + ShowHelpArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // SHOWHELPARGPARSER_H diff --git a/libqnapi/src/parser/showhelplanguagesargparser.cpp b/libqnapi/src/parser/showhelplanguagesargparser.cpp new file mode 100644 index 0000000..05122c8 --- /dev/null +++ b/libqnapi/src/parser/showhelplanguagesargparser.cpp @@ -0,0 +1,33 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "showhelplanguagesargparser.h" +#include "qnapicommand.h" + +ShowHelpLanguagesArgParser::ShowHelpLanguagesArgParser() {} + +QVariant ShowHelpLanguagesArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + if (args.contains("-hl") || args.contains("--help-languages")) { + return QVariant::fromValue(ParsedCommand{ + config, QVariant::fromValue(QNapiCommand::ShowHelpLanguages())}); + } else { + return QVariant::fromValue(NothingParsed()); + } +} + +Maybe ShowHelpLanguagesArgParser::helpInfo() const { + return just(HelpInfo{"-hl", "--help-languages", "", + tr("List of available subtitles languages")}); +} diff --git a/libqnapi/src/parser/showhelplanguagesargparser.h b/libqnapi/src/parser/showhelplanguagesargparser.h new file mode 100644 index 0000000..fb642df --- /dev/null +++ b/libqnapi/src/parser/showhelplanguagesargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef SHOWHELPLANGUAGESARGPARSER_H +#define SHOWHELPLANGUAGESARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class ShowHelpLanguagesArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(ShowHelpLanguagesArgParser) + + public: + ShowHelpLanguagesArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // SHOWHELPLANGUAGESARGPARSER_H diff --git a/libqnapi/src/parser/showlistargparser.cpp b/libqnapi/src/parser/showlistargparser.cpp new file mode 100644 index 0000000..cf54fe3 --- /dev/null +++ b/libqnapi/src/parser/showlistargparser.cpp @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "showlistargparser.h" +#include "qnapicommand.h" + +ShowListArgParser::ShowListArgParser() {} + +QVariant ShowListArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + if (args.contains("-s") || args.contains("--show-list")) { + return QVariant::fromValue(ParsedModifier{ + config.setGeneralConfig(config.generalConfig().setDownloadPolicy( + DownloadPolicy::DP_ALWAYS_SHOW_LIST))}); + } else { + return QVariant::fromValue(NothingParsed()); + } +} + +Maybe ShowListArgParser::helpInfo() const { + return just(HelpInfo{"-s", "--show-list", "", + tr("Always show a list of available subtitles")}); +} diff --git a/libqnapi/src/parser/showlistargparser.h b/libqnapi/src/parser/showlistargparser.h new file mode 100644 index 0000000..b341551 --- /dev/null +++ b/libqnapi/src/parser/showlistargparser.h @@ -0,0 +1,34 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef SHOWLISTARGPARSER_H +#define SHOWLISTARGPARSER_H + +#include +#include "parser/cliargparser.h" +#include "tr.h" + +class ShowListArgParser : public CliArgParser { + Q_DECLARE_CLASS_TR(ShowListArgParser) + + public: + ShowListArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; + + virtual Maybe helpInfo() const; +}; + +#endif // SHOWLISTARGPARSER_H diff --git a/libqnapi/src/parser/showoptionsargparser.cpp b/libqnapi/src/parser/showoptionsargparser.cpp new file mode 100644 index 0000000..ec8e7a2 --- /dev/null +++ b/libqnapi/src/parser/showoptionsargparser.cpp @@ -0,0 +1,28 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "qnapicommand.h" +#include "showoptionsargparser.h" + +ShowOptionsArgParser::ShowOptionsArgParser() {} + +QVariant ShowOptionsArgParser::parse(const QStringList& args, + const QNapiConfig& config) const { + if (args.contains("-o") || args.contains("--options")) { + return QVariant::fromValue(ParsedCommand{ + config, QVariant::fromValue(QNapiCommand::ShowOptions())}); + } else { + return QVariant::fromValue(NothingParsed()); + } +} diff --git a/libqnapi/src/parser/showoptionsargparser.h b/libqnapi/src/parser/showoptionsargparser.h new file mode 100644 index 0000000..7c9bf3e --- /dev/null +++ b/libqnapi/src/parser/showoptionsargparser.h @@ -0,0 +1,28 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef SHOWOPTIONS_H +#define SHOWOPTIONS_H + +#include "parser/cliargparser.h" + +class ShowOptionsArgParser : public CliArgParser { + public: + ShowOptionsArgParser(); + + virtual QVariant parse(const QStringList& args, + const QNapiConfig& config) const; +}; + +#endif // SHOWOPTIONS_H diff --git a/gui/src/qnapi.cpp b/libqnapi/src/qnapi.cpp similarity index 100% rename from gui/src/qnapi.cpp rename to libqnapi/src/qnapi.cpp diff --git a/gui/src/qnapi.h b/libqnapi/src/qnapi.h similarity index 100% rename from gui/src/qnapi.h rename to libqnapi/src/qnapi.h diff --git a/libqnapi/src/qnapicommand.h b/libqnapi/src/qnapicommand.h new file mode 100644 index 0000000..74e5b4f --- /dev/null +++ b/libqnapi/src/qnapicommand.h @@ -0,0 +1,58 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef QNAPICOMMAND_H +#define QNAPICOMMAND_H + +#include +#include +#include + +namespace QNapiCommand { + +struct RunCLIApp { + QStringList arguments; +}; + +struct DownloadSubtitles { + QStringList movieFilePaths; +}; + +struct ScanDirectory { + QString directory; +}; + +// not implemented yet +// struct ConvertSubtitles { +// QString subtitlesPath; +//}; + +struct ShowOptions {}; + +struct ShowHelp {}; + +struct ShowHelpLanguages {}; + +} // namespace QNapiCommand + +Q_DECLARE_METATYPE(QNapiCommand::RunCLIApp) +Q_DECLARE_METATYPE(QNapiCommand::DownloadSubtitles) +Q_DECLARE_METATYPE(QNapiCommand::ScanDirectory) +// not implemented yet +// Q_DECLARE_METATYPE(QNapiGuiCommand::ConvertSubtitles) +Q_DECLARE_METATYPE(QNapiCommand::ShowOptions) +Q_DECLARE_METATYPE(QNapiCommand::ShowHelp) +Q_DECLARE_METATYPE(QNapiCommand::ShowHelpLanguages) + +#endif // QNAPICOMMAND_H diff --git a/libqnapi/src/subtitlelanguage.h b/libqnapi/src/subtitlelanguage.h index 5c80a5e..2ef6e0c 100644 --- a/libqnapi/src/subtitlelanguage.h +++ b/libqnapi/src/subtitlelanguage.h @@ -38,4 +38,6 @@ class SubtitleLanguage { void fill_tables(); }; +Q_DECLARE_METATYPE(SubtitleLanguage) + #endif diff --git a/libqnapi/src/tr.h b/libqnapi/src/tr.h new file mode 100644 index 0000000..638bed0 --- /dev/null +++ b/libqnapi/src/tr.h @@ -0,0 +1,35 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef NAMESPACE_TR_H +#define NAMESPACE_TR_H + +#include + +#define Q_DECLARE_NAMESPACE_TR(context) \ + inline QString tr(const char *sourceText, \ + const char *disambiguation = Q_NULLPTR, int n = -1) { \ + return QCoreApplication::translate(#context, sourceText, disambiguation, \ + n); \ + } + +#define Q_DECLARE_CLASS_TR(context) \ + inline QString tr(const char *sourceText, \ + const char *disambiguation = Q_NULLPTR, int n = -1) \ + const { \ + return QCoreApplication::translate(#context, sourceText, disambiguation, \ + n); \ + } + +#endif // NAMESPACE_TR_H diff --git a/libqnapi/src/utils/console.cpp b/libqnapi/src/utils/console.cpp new file mode 100644 index 0000000..6a2b153 --- /dev/null +++ b/libqnapi/src/utils/console.cpp @@ -0,0 +1,69 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "console.h" + +#include + +Console::Console(bool isQuiet) : isQuiet(isQuiet) {} + +void Console::printLine(const QString& line) const { + if (isQuiet) return; + std::cout << line.toStdString() << std::endl; +} + +void Console::print(const QString& line) const { + if (isQuiet) return; + std::cout << line.toStdString(); +} + +void Console::printLineHighlihted(const QString& line) const { + printLine(" * " + line); +} + +void Console::printLineOrdinary(const QString& line) const { + printLine(" " + line); +} + +void Console::printOrdinary(const QString& line) const { print(" " + line); } + +void Console::printLineError(const QString& line) const { + printLine("!! " + line); +} + +void Console::printLineWarning(const QString& line) const { + printLine(" ! " + line); +} + +int Console::inputNumber(const QString& message, int min, int max) const { + bool ok = false; + int number = 0; + + while (!ok) { + printOrdinary(message); + char line[16]; + std::cin.getline(line, 16); + number = QString(line).toInt(&ok); + if (!ok) { + printLineWarning(tr("You must enter a number!")); + std::cin.clear(); + } else if (number < min || number > max) { + ok = false; + printLineWarning( + tr("You must enter a number between %1 and %2").arg(min).arg(max)); + } + } + + return number; +} diff --git a/libqnapi/src/utils/console.h b/libqnapi/src/utils/console.h new file mode 100644 index 0000000..201ee59 --- /dev/null +++ b/libqnapi/src/utils/console.h @@ -0,0 +1,39 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef CONSOLE_H +#define CONSOLE_H + +#include +#include + +class Console { + Q_DECLARE_TR_FUNCTIONS(Console) + + bool isQuiet; + + public: + Console(bool isQuiet = false); + void printLine(const QString& line = "") const; + void print(const QString& line) const; + void printLineHighlihted(const QString& line) const; + void printLineOrdinary(const QString& line) const; + void printOrdinary(const QString& line) const; + void printLineError(const QString& line) const; + void printLineWarning(const QString& line) const; + + int inputNumber(const QString& message, int min, int max) const; +}; + +#endif // CONSOLE_H diff --git a/libqnapi/src/utils/helphelper.cpp b/libqnapi/src/utils/helphelper.cpp new file mode 100644 index 0000000..0698d86 --- /dev/null +++ b/libqnapi/src/utils/helphelper.cpp @@ -0,0 +1,42 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#include "helphelper.h" +#include "libqnapi.h" +#include "parser/cliargparsersexecutor.h" + +namespace HelpHelper { + +QStringList formatHelpLinesText( + const QList> &cliArgParsers, + int switchesBlockSize, int descBlockSize, int preSwitchSpaceSize) { + QString binaryFileName = + QFileInfo(LibQNapi::appExecutableFilePath).fileName(); + + QStringList helpLines; + + helpLines << tr( + "QNapi is distributed under the GNU General Public License v2."); + helpLines << ""; + + helpLines << tr("Syntax: %1 [options] [list of files]").arg(binaryFileName); + helpLines << tr("Available options:"); + + helpLines << CliArgParsersExecutor::formatHelpLines( + cliArgParsers, switchesBlockSize, descBlockSize, preSwitchSpaceSize); + + return helpLines; +} + +} // namespace HelpHelper diff --git a/libqnapi/src/utils/helphelper.h b/libqnapi/src/utils/helphelper.h new file mode 100644 index 0000000..cebb7ae --- /dev/null +++ b/libqnapi/src/utils/helphelper.h @@ -0,0 +1,33 @@ +/***************************************************************************** +** QNapi +** Copyright (C) 2008-2017 Piotr Krzemiński +** +** This program 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 2 of the License, or +** (at your option) any later version. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*****************************************************************************/ + +#ifndef HELPHELPER_H +#define HELPHELPER_H + +#include +#include +#include "parser/cliargparser.h" +#include "tr.h" + +namespace HelpHelper { +Q_DECLARE_NAMESPACE_TR(HelpHelper) + +QStringList formatHelpLinesText( + const QList> &cliArgParsers, + int switchesBlockSize = 30, int descBlockSize = 50, + int preSwitchSpaceSize = 2); + +}; // namespace HelpHelper + +#endif // HELPHELPER_H diff --git a/qnapi.pro b/qnapi.pro index 9751cf6..1e1b5de 100644 --- a/qnapi.pro +++ b/qnapi.pro @@ -2,15 +2,32 @@ TEMPLATE = subdirs CONFIG += ordered -SUBDIRS = libqnapi gui +SUBDIRS = libqnapi cli gui + +no_cli:message(will skip building qnapic cli application) +no_cli:SUBDIRS -= cli + +no_gui:message(will skip building qnapi gui application) +no_gui:SUBDIRS -= gui TRANSLATIONS += translations/qnapi_it.ts translations/qnapi_pl.ts unix { INSTALL_PREFIX = /usr DATADIR=$${INSTALL_PREFIX}/share - target.files += qnapi - target.path = $${INSTALL_PREFIX}/bin + + !no_cli { + cli_target.files = qnapic + cli_target.path = $${INSTALL_PREFIX}/bin + INSTALLS += cli_target + } + + !macx:!no_gui { + gui_target.files = qnapi + gui_target.path = $${INSTALL_PREFIX}/bin + INSTALLS += gui_target + } + doc.path = $${INSTALL_PREFIX}/share/doc/qnapi doc.files = doc/ChangeLog \ doc/LICENSE \ @@ -40,10 +57,10 @@ unix { desktop.path = $${INSTALL_PREFIX}/share/applications desktop.files = doc/qnapi.desktop - INSTALLS += target doc man man_it man_pl desktop + INSTALLS += doc man man_it man_pl desktop } -macx { +macx:!no_gui { macdeploy.commands = macdeployqt macx/QNapi.app appdmg.depends = macdeploy appdmg.commands = appdmg macx/appdmg.json macx/QNapi.dmg @@ -72,7 +89,10 @@ win32 { libmediainfodlls.files += deps/libmediainfo/bin/MediaInfo.dll libmediainfodlls.path = $${INSTALL_PREFIX} - deploywin.commands = windeployqt --no-translations --no-quick-import --no-system-d3d-compiler --no-angle --no-webkit --no-webkit2 win32/out/qnapi.exe + DEPLOYWIN_FLAGS = --no-translations --no-quick-import --no-system-d3d-compiler --no-angle --no-webkit --no-webkit2 + deploywin.commands += windeployqt $${DEPLOYWIN_FLAGS} + !no_cli:deploywin.commands += win32/out/qnapic.exe + !no_gui:deploywin.commands += win32/out/qnapi.exe platform.files = $$[QT_INSTALL_PLUGINS]/platforms/qwindows.dll platform.path = $${INSTALL_PREFIX}/platforms diff --git a/scripts/version.sh b/scripts/version.sh index 12e0125..44b55af 100755 --- a/scripts/version.sh +++ b/scripts/version.sh @@ -1,3 +1,4 @@ #!/bin/sh VERSION_FILE=libqnapi/src/version.h -cat $VERSION_FILE | grep QNAPI_DISPLAYABLE_VERSION | awk '{gsub(/"/, "", $3); print $3}' +(grep QNAPI_DISPLAYABLE_VERSION | awk '{gsub(/"/, "", $3); print $3}') < $VERSION_FILE + diff --git a/translations/qnapi_it.qm b/translations/qnapi_it.qm index 98d709a..0f9bf61 100644 Binary files a/translations/qnapi_it.qm and b/translations/qnapi_it.qm differ diff --git a/translations/qnapi_it.ts b/translations/qnapi_it.ts index 2413028..fce3cba 100644 --- a/translations/qnapi_it.ts +++ b/translations/qnapi_it.ts @@ -2,385 +2,480 @@ - GetThread + BackupLangArgParser - - Checking permissions of the video directory... - Controllo permessi della cartella video... + + You need to pass backup language code after %1 argument + È necessario passare il codice della lingua di backup dopo l'argomento %1 - - No permission to write to the directory '%1'! - Mancano i permessi per scrivere nella cartella '%1'! + + Invalid backup language code passed: %1 + Codice lingua non valido: %1 - - Calculating checksum of the file... - Calcolo checksum del file... + + code + codice + + + + Alternative subtitles language + Lingua sottotitoli alternativa + + + + CliMain + + + QNapi %1 (Qt version %2), %3 + QNapi %1 (versione Qt %2), %3 + + + + List of languages recognized by QNapi, including corresponding + Lista delle lingue riconosciute da QNapi, inclusi i corrispondenti - - + + two-letter language codes: + codici lingua a due lettere: + + + + Current default subtitles language: %1 (%2) + Lingua sottotitoli predefinita corrente: %1 (%2) + + + + No alternative subtitles language has been set + Non è stata impostata alcuna lingua sottotitoli alternativa + + + + Current alternative subtitles language: %1 (%2) + Lingua sottotitoli alternativa corrente: %1 (%2) + + + + QNapi: deleting temporary files... + QNapi: eliminazione file temporanei... + + + + QNapi: finished. + QNapi: operazione conclusa. + + + + Command line argument parsing error: + Errore di analisi dell'argomento della riga di comando: + + + + CliSubtitlesDownloader + + + Invalid path to p7zip executable: %1 + Il percorso al programma p7zip è errato: %1 + + + + Can't write to temporary directory: %1 + Impossibile scrivere nella cartella temporanea: %1 + + + + Calculating checksums... + Calcolo checksum... + + + + Searching for subtitles [%1] (%2)... Ricerca sottotitoli [%1] (%2)... - - + + Searching for subtitles in alternative language [%1] (%2)... Ricerca sottotitoli in lingua alternativa [%1] (%2)... - - Downloading subtitles file... - Scaricamento file sottotitoli... + + 0) Do not download subtitles for this video + 0) Non scaricare sottotitoli per questo video - - Unpacking subtitles file... - Scompattamento file sottotitoli... + + Found subtitles: + Trovati sottotitoli: - - Post-processing subtitles... - Post-elaborazione sottotitoli... + + (good) + (buona qualità) - - Adjusting subtitles... - Adattamento sottotitoli... + + (bad) + (cattiva qualità) - - Could not adjust subtitles! - Impossibile adattare i sottotitoli! + + Select subtitles to download: + Selezionare sottotitoli da scaricare: - - - MaiaObject - - parse error: invalid xml-rpc. not conforming to spec. - analizza l'errore: xml-rpc non valido. non conforme alle specifiche. + + Downloading subtitles... + Scaricamento sottotitoli... - - - QNapiApp - - - - - Download subtitles - Scarica sottotitoli + + Unable to download subtitles! + Impossibile scaricare sottotitoli! - - Scan directories - Scansiona cartelle + + Unpacking subtitles... + Scompattamento sottotitoli... - - Convert subtitles - Converti sottotitoli + + Failed to unpack subtitles! + Impossibile scompattare i sottotitoli! - - - - Create an account - Crea un account + + Post-processing subtitles file... + Post-elaborazione file sottotitoli... - - Upload subtitles - Invia sottotitoli + + Adjusting subtitles... + Adattamento sottotitoli... - - Settings - Impostazioni + + Could not adjust subtitles! + Impossibile adattare i sottotitoli! - - About - Informazioni + + Downloading subtitles for '%1' [%2/%3] + Scaricamento sottotitoli per '%1' [%2/%3] - - Quit - Esci + + No permission to write to the directory '%1'! + Mancano i permessi per scrivere nella cartella '%1'! - - NapiProjekt - NapiProjekt + + Subtitles not found! + Sottotitoli non trovati! - - - OpenSubtitles - OpenSubtitles + + + Processing of remaining %n file(s) was ignored due to critical error. + + L'elaborazione di un file rimanente è stato ignorato a causa di un errore critico. + L'elaborazione di %n file rimanenti è stata ignorata a causa di un errore critico. + + + + Console - - Napisy24 - Napisy24 + + You must enter a number! + È necessario inserire un numero! - - Select one or more video files to download subtitles for - Scegli uno o più video file per cui scaricare sottotitoli + + You must enter a number between %1 and %2 + Inserisci un numero compreso tra %1 e %2 - QNapiCli + DontShowListArgParser - - Invalid language code: %1 - Codice lingua non valido: %1 + + Never show a list of available subtitles + Non mostrare una lista di sottotitoli + + + ExtensionArgParser - - Invalid target subtitles format: %1 - Formato sottotitoli destinazione non valido: %1 + + You need to pass subtitles extension after %1 argument + È necessario passare l'estensione dei sottotitoli dopo l'argomento %1 - - File not found! - File non trovato! + + Invalid target subtitles extension passed: %1 + L'estensione del sottotitolo non valida è passata: %1 - - Path to the program p7zip is incorrect! Check your settings. - Il percorso al programma p7zip è errato! Controllare le impostazioni. + + ext + ext - - Can not write to the temporary directory! Check your settings. - Impossibile scrivere nella cartella temporanea! Controllare le impostazioni. + + Select target subtitles file extension + Selezione estensione file sottotitoli destinazione + + + FormatArgParser - - * Downloading subtitles for '%1' - * Scaricamento sottotitoli per '%1' + + You need to pass subtitles format code after %1 argument + È necessario passare il codice di formato del sottotitolo dopo l'argomento %1 - - No permission to write to the directory '%1'! - Mancano i permessi per scrivere nella cartella '%1'! + + Invalid target subtitles format passed: %1 + Formato sottotitoli destinazione non valido: %1 - - Calculating checksums... - Calcolo checksum... + + format + formato - - - Searching for subtitles [%1] (%2)... - Ricerca sottotitoli [%1] (%2)... + + Select target subtitles file format (one of mDVD, MPL2, SRT, TMP) + Seleziona formato file sottotitoli destinazione (mDVD, MPL2, SRT, TMP) + + + GetThread - - - Searching for subtitles in alternative language [%1] (%2)... - Ricerca sottotitoli in lingua alternativa [%1] (%2)... + + Checking permissions of the video directory... + Controllo permessi della cartella video... - - Subtitles not found! - Sottotitoli non trovati! + + No permission to write to the directory '%1'! + Mancano i permessi per scrivere nella cartella '%1'! - - 0) Do not download subtitles for this video - 0) Non scaricare sottotitoli per questo video + + Calculating checksum of the file... + Calcolo checksum del file... - - Found subtitles: - Trovati sottotitoli: + + + Searching for subtitles [%1] (%2)... + Ricerca sottotitoli [%1] (%2)... - - (good) - (buona qualità) + + + Searching for subtitles in alternative language [%1] (%2)... + Ricerca sottotitoli in lingua alternativa [%1] (%2)... - - (bad) - (cattiva qualità) + + Downloading subtitles file... + Scaricamento file sottotitoli... - - Select subtitles to download: - Selezionare sottotitoli da scaricare: + + Unpacking subtitles file... + Scompattamento file sottotitoli... - - You must enter a number! - È necessario inserire un numero! + + Post-processing subtitles... + Post-elaborazione sottotitoli... - - Enter a number from the list! - Inserire un numero dalla lista! + + Adjusting subtitles... + Adattamento sottotitoli... - - Downloading subtitles... - Scaricamento sottotitoli... + + Could not adjust subtitles! + Impossibile adattare i sottotitoli! + + + GuiMain - - Unable to download subtitles! - Impossibile scaricare sottotitoli! + + List of languages recognized by QNapi, including corresponding + Lista delle lingue riconosciute da QNapi, inclusi i corrispondenti - - Unpacking subtitles... - Scompattamento sottotitoli... + + two-letter language codes: + codici lingua a due lettere: - - Failed to unpack subtitles! - Impossibile scompattare i sottotitoli! + + Current default subtitles language: %1 (%2) + Lingua sottotitoli predefinita corrente: %1 (%2) - - Post-processing subtitles file... - Post-elaborazione file sottotitoli... + + No alternative subtitles language has been set + Non è stata impostata alcuna lingua sottotitoli alternativa - - Adjusting subtitles... - Adattamento sottotitoli... + + Current alternative subtitles language: %1 (%2) + Lingua sottotitoli alternativa corrente: %1 (%2) - - Could not adjust subtitles! - Impossibile adattare i sottotitoli! + + QNapi - command line argument parsing error + QNapi - errore di analisi dell'argomento della riga di comando - - QNapi %1, %2 - QNapi %1, %2 + + QNapi - CLI executable not found + QNapi - versione per riga di comando non trovata - - Qt version: %1 - Versione Qt: %1 + + You have requested to run QNapi in command-line mode, but unfortunately command-line binary '%1' could not be found. + Ha richiesto l'avvio dell'applicazione della riga di comando, ma il binario '%1' non è stato trovato. + + + HelpHelper - + QNapi is distributed under the GNU General Public License v2. QNapi è distribuito sotto la GNU General Public License v2. - + Syntax: %1 [options] [list of files] Sintassi: %1 [opzioni] [lista file] - + Available options: Opzioni disponibili: + + + LangArgParser - - -c, --console Download subtitles with console - -c, --console Scarica sottotitoli da console + + You need to pass language code after %1 argument + È necessario passare il codice di lingua dopo l'argomento %1 - - -q, --quiet Download subtitles quietly without showing - -q, --quiet Scarica sottotitoli in silenzio senza mostrare + + Invalid language code passed: %1 + Codice lingua non valido: %1 - - any messages or windows (implies -d) - alcun messaggio o finestra (sottintende -d) + + code + codice - - -s, --show-list Show a list of subtitles (works only with -c) - -s, --show-list Mostra una lista di sottotitoli (funziona solo con -c) + + Preferred subtitles language + Lingua sottotitoli preferita + + + MaiaObject - - -d, --dont-show-list Do not show a list of subtitles (works only with -c) - -d, --dont-show-list Non mostrare una lista di sottotitoli (funziona solo con -c) + + parse error: invalid xml-rpc. not conforming to spec. + analizza l'errore: xml-rpc non valido. non conforme alle specifiche. + + + QNapiApp - - -l, --lang [code] Preferred subtitles language - -l, --lang [codice] Lingua sottotitoli preferita + + + + + Download subtitles + Scarica sottotitoli - - -lb,--lang-backup [code] Alternative subtitles language - -lb,--lang-backup [codice] Lingua sottotitoli alternativa + + Scan directories + Scansiona cartelle - - -f, --format [format] Select target subtitles file format (%1) - -f, --format [formato] Seleziona formato file sottotitoli destinazione (%1) + + Convert subtitles + Converti sottotitoli - - -e, --extension [ext] Select target subtitles file extension - -e, --extension [est] Selezione estensione file sottotitoli destinazione + + + + Create an account + Crea un account - - -o, --options Show program options (only GUI) - -o, --options Mostra opzioni programma (solo GUI) + + Upload subtitles + Invia sottotitoli - - -h, --help Show help text - -h, --help Mostra testo di aiuto + + Settings + Impostazioni - - -hl,--help-languages List of available subtitles languages - -hl,--help-languages Lista delle lingue sottotitoli disponibili + + About + Informazioni - - List of languages recognized by QNapi, including corresponding - Lista delle lingue riconosciute da QNapi, inclusi i corrispondenti + + Quit + Esci - - two-letter language codes: - codici lingua a due lettere: + + NapiProjekt + NapiProjekt - - Current default subtitles language: %1 (%2) - Lingua sottotitoli predefinita corrente: %1 (%2) + + OpenSubtitles + OpenSubtitles - - No alternative subtitles language has been set - Non è stata impostata alcuna lingua sottotitoli alternativa + + Napisy24 + Napisy24 - - Current alternative subtitles language: %1 (%2) - Lingua sottotitoli alternativa corrente: %1 (%2) + + Select one or more video files to download subtitles for + Scegli uno o più video file per cui scaricare sottotitoli QNapiOpenDialog - + Video files (%1);;All files (*.*) File video (%1);;Tutti i file (*.*) - + Subtitles files (%1);;All files (*.*) File sottotitoli (%1);;Tutti i file(*.*) @@ -388,7 +483,7 @@ QObject - + <b>www.napiprojekt.pl</b> subtitles download engine Motore scaricamento sottotitoli <b>www.napiprojekt.pl</b> @@ -398,230 +493,270 @@ Motore scaricamento sottotitoli <b>www.napisy24.pl</b> - + <b>www.opensubtitles.org</b> subtitles download engine Motore scaricamento sottotitoli <b>www.opensubtitles.org</b> - + Subtitles downloaded and processed by QNapi| Sottotitoli scaricati e processati da QNapi | - + Albanian Albanese - + English Inglese - + Arabic Arabo - + Bulgarian Bulgaro - + Chinese Cinese - + Croatian Croato - + Czech Ceco - + Danish Danese - + Estonian Estone - + Finnish Finlandese - + French Francese - + Galician Gallego - + Greek Greco - + Hebrew Ebraico - + Spanish Spagnolo - + Dutch Olandese - + Indonesian Indonesiano - + Japanese Giapponese - + Korean Coreano - + Macedonian Macedone - + German Tedesco - + Norwegian Norvegese - + Occitan Occitano - + Persian (farsi) Persiano (farsi) - + Polish Polacco - + Portuguese Portoghese - + Portuguese-BR Portoghese-BR - + Russian Russo - + Romanian Romeno - + Serbian Serbo - + Slovenian Sloveno - + Swedish Svedese - + Slovak Slovacco - + Turkish Turco - + Vietnamese Vietnamita - + Hungarian Ungherese - + Italian Italiano - + First Run Prima esecuzione - + This is the first launch of the program QNapi. Do you want to configure it now? Questa è la prima esecuzione del programma QNapi. Vuoi configurarlo adesso? - + QNapi: deleting temporary files... QNapi: eliminazione file temporanei... - + QNapi: finished. QNapi: operazione conclusa. - + No subtitles found! Nessun sottotitolo trovato! + + QuietBatchArgParser + + + Download subtitles silently without showing any messages + Scarica sottotitoli in silenzio senza mostrare alcun messaggio o finestra (sottintende -d) + + + + RunCLIAppArgParser + + + Run in command-line mode (requires separate CLI binary) + Esegui in modalità riga di comando (richiede binario separato) + + + + ShowHelpArgParser + + + Show help text + Mostra testo di aiuto + + + + ShowHelpLanguagesArgParser + + + List of available subtitles languages + Lista delle lingue sottotitoli disponibili + + + + ShowListArgParser + + + Always show a list of available subtitles + Mostra una lista di sottotitoli + + SubtitleMatcher - + _copy _copia @@ -634,37 +769,32 @@ QNapi - Informazioni - + <html><head/><body><p>QNapi is a program for automatic downloading and matching subtitles for movies. </p><p>The program is distributed under the GNU General Public License version second or later.</p><p><a href="http://qnapi.github.io"><span style=" text-decoration: underline; color:#0000ff;">http://qnapi.github.io</span></a></p><p>I thank all those who in any way supported the development of the project.</p></body></html> <html><head/><body><p>QNapi è un programma per lo scaricamento e l'abbinamento automatico di sottotitoli di film. </p><p>Il programma è distribuito sotto la GNU General Public License seconda versione o successiva.</p><p><a href="http://qnapi.github.io"><span style=" text-decoration: underline; color:#0000ff;">http://qnapi.github.io</span></a></p><p>Ringrazio tutti coloro che hanno supportato lo sviluppo del progetto in qualunque forma.</p></body></html> - + Qt version: x.y.z Versione Qt: x.y.z - + The program uses www.napiprojekt.pl subtitle database Questo programma usa il database sottotitoli www.napiprojekt.pl - + The program uses www.opensubtitles.org subtitle database Questo programma usa il database sottotitoli www.opensubtitles.org - + The program uses www.napisy24.pl subtitle database Questo programma usa il database sottotitoli www.napisy24.pl - - Close - Chiudi - - - + QNapi version Versione QNapi @@ -821,44 +951,44 @@ Converti - + Choose a subtitles file Scegliere un file sottotitoli - + incorrect errato - + Default (%1) Predefinita (%1) - - + + Select a video file Selezionare un file video - + Subtitles converted Sottotitoli convertiti - + Changed subtitles format from '%1' to '%2' convertito? Formato sottotitoli cambiato da '%1' a '%2' - + Could not change subtitle format! Impossibile cambiare formato sottotitoli! - + An error occured while converting subtitles! Si è verificato un errore durante la conversione dei sottotitoli! @@ -896,17 +1026,17 @@ I sottotitoli <b>probabilmente non corrispondenti</b> al video sono evidenziati in rosso. - + Select the subtitles which you want to download for video file<br><br><b>%1</b> Seleziona i sottotitoli che vuoi scaricare per il file video<br><br><b>%1</b> - + No subtitle selected Nessun sottotitolo selezionato - + You need to select a subtitle from the list! È necessario selezionare un sottotitolo dalla lista! @@ -1050,7 +1180,7 @@ Subtitles file permissions: - Permessi file sottotitoli: + Permessi file sottotitoli: @@ -1074,7 +1204,7 @@ - + Auto-detected based on system language (%1) Autorilevamento in base alla lingua di sistema (%1) @@ -1144,7 +1274,7 @@ Move down - Sposta in giù + Sposta in giù @@ -1229,7 +1359,7 @@ - + Default Predefinita @@ -1264,17 +1394,17 @@ Salva - + Specify the path for 7z executable Specificare il percorso per l'eseguibile 7z - + Invalid path Percorso non valido - + Defined path to 7z executable is invalid. If you can not locate 7z executable, try installing p7zip-full package. Il percorso all'eseguibile 7z definito non è valido. Se non si riesce a trovare l'eseguibile 7z, provare a installare il pacchetto completo p7zip. @@ -1284,22 +1414,22 @@ Specificare cartella temporanea - + Warning Avviso - + At least one subtitles engine must remain active! Almeno uno dei motori sottotitoli deve rimanere attivo! - + %1 subtitles engine info Info motore sottotitoli %1 - + Default (%1) Predefinita (%1) @@ -1322,62 +1452,62 @@ Annulla - + Can not find p7zip! Impossibile trovare p7zip! - + The path to the program p7zip is incorrect! Il percorso al programma p7zip è errato! - + Invalid temporary directory! Cartella temporanea non valida! - + Unable to write to the temporary directory! Check your settings. Impossibile scrivere nella cartella temporanea! Controllare le impostazioni. - + No files! Nessun file! - + Can't download subtitles as no movie files specified! Impossibile scaricare sottotitoli dato che nessun file film è stato specificato! - + QNapi - downloading subtitles (%1/%2) QNapi - scaricamento sottotitoli (%1/%2) - + QNapi - downloading subtitles... QNapi - scaricamento sottotitoli... - + Critical error! Errore critico! - + QNapi QNapi - + Do you want to cancel subtitles downloading? Si desidera annullare lo scaricamento dei sottotitoli? - + Finishing the tasks... Conclusione operazioni in corso... @@ -1396,7 +1526,7 @@ - + Scan Scansiona @@ -1452,7 +1582,7 @@ - + Cancel Annulla @@ -1467,32 +1597,32 @@ Segui collegamenti simbolici - + Select the folder to scan Seleziona la cartella da scansionare - + Scanning directories... Scansione cartelle... - + Interrupting directory scanning... Arresto scansione cartelle... - + Scanning directory <b>%1</b>... Scansione cartella <b>%1</b>... - + Select the videos you wish to download subtitles for. Seleziona i video per cui si desidera scaricare sottotitoli. - + No video files found. Nessun file video trovato. @@ -1520,24 +1650,24 @@ OK - + Subtitles downloaded for %1 %2 Scaricati sottotitoli per %1 %2 - + files file - + file file - + Could not download subtitles for %1 %2 Impossibile scaricare sottotitoli per %1 %2 diff --git a/translations/qnapi_pl.qm b/translations/qnapi_pl.qm index 47df9fe..c4adfdf 100644 Binary files a/translations/qnapi_pl.qm and b/translations/qnapi_pl.qm differ diff --git a/translations/qnapi_pl.ts b/translations/qnapi_pl.ts index 5bcee22..54e8fd6 100644 --- a/translations/qnapi_pl.ts +++ b/translations/qnapi_pl.ts @@ -2,385 +2,481 @@ - GetThread + BackupLangArgParser - - Checking permissions of the video directory... - Sprawdzanie uprawnień do katalogu z filmem... + + You need to pass backup language code after %1 argument + Musisz podać kod języka zapasowego po argumencie %1 - - No permission to write to the directory '%1'! - Brak uprawnień zapisu do katalogu '%1'! + + Invalid backup language code passed: %1 + Niepoprawny kod jezykowy: %1 - - Calculating checksum of the file... - Obliczanie sumy kontrolnej pliku... + + code + kod + + + + Alternative subtitles language + Zapasowy język pobierania napisów + + + + CliMain + + + QNapi %1 (Qt version %2), %3 + QNapi %1 (wersja Qt %2), %3 + + + + List of languages recognized by QNapi, including corresponding + Oto lista rozpoznawanych przez QNapi jezykow i odpowiadajacym + + + + two-letter language codes: + im dwuliterowych kodow: + + + + Current default subtitles language: %1 (%2) + Aktualnie ustawiony preferowany jezyk pobierania napisow: %1 (%2) + + + + No alternative subtitles language has been set + Brak ustawionego zapasowego jezyka napisow + + + + Current alternative subtitles language: %1 (%2) + Aktualnie ustawiony zapasowy jezyk napisow: %1 (%2) + + + + QNapi: deleting temporary files... + + + + + QNapi: finished. + + + + + Command line argument parsing error: + + + + + CliSubtitlesDownloader + + + Invalid path to p7zip executable: %1 + Sciezka do programu p7zip jest nieprawidlowa: %1 + + + + Can't write to temporary directory: %1 + Nie mozna pisac do katalogu tymczasowego: %1 + + + + Calculating checksums... + Obliczanie sum kontrolnych... - - + + Searching for subtitles [%1] (%2)... Szukanie napisów [%1] (%2)... - - + + Searching for subtitles in alternative language [%1] (%2)... Szukanie napisów w języku zapasowym [%1] (%2)... - - Downloading subtitles file... - Pobieranie napisów dla pliku... + + 0) Do not download subtitles for this video + 0) Nie pobieraj napisow dla tego filmu - - Unpacking subtitles file... - Rozpakowywanie napisów... + + Found subtitles: + Znaleziono napisy: - - Post-processing subtitles... - Przetwarzanie napisów... + + (good) + (dobre) - - Adjusting subtitles... - Dopasowywanie napisów... + + (bad) + (zle) - - Could not adjust subtitles! - Nie udało się dopasować napisów! + + Select subtitles to download: + Wybierz napisy do pobrania: - - - MaiaObject - - parse error: invalid xml-rpc. not conforming to spec. - błąd parsowania: niepoprawny xml-rpc. niezgodny ze specyfikacją. + + Downloading subtitles... + Pobieranie napisow... - - - QNapiApp - - - - - Download subtitles - Pobierz napisy + + Unable to download subtitles! + Nie udalo sie pobrac napisow! - - Scan directories - Skanuj katalogi + + Unpacking subtitles... + Rozpakowywanie napisow... - - Convert subtitles - Konwertuj napisy + + Failed to unpack subtitles! + Nie udalo sie rozpakowac napisow! - - - - Create an account - Załóż konto + + Post-processing subtitles file... + Przetwarzanie napisow... - - Upload subtitles - Wyślij napisy + + Adjusting subtitles... + Dopasowywanie napisów... - - Settings - Ustawienia + + Could not adjust subtitles! + Nie udało się dopasować napisów! - - About - O programie + + Downloading subtitles for '%1' [%2/%3] + Pobieranie napisow dla '%1' [%2/%3] - - Quit - Zakończ + + No permission to write to the directory '%1'! + Brak uprawnień zapisu do katalogu '%1'! - - NapiProjekt - NapiProjekt + + Subtitles not found! + Nie znaleziono napisow! - - - OpenSubtitles - OpenSubtitles + + + Processing of remaining %n file(s) was ignored due to critical error. + + Pobieranie pozostalego 1 pliku przerwane z powodu bledu. + Pobieranie pozostalych %n plikow przerwane z powodu bledu. + Pobieranie pozostalych %n plikow przerwane z powodu bledu. + + + + Console - - Napisy24 - Napisy24 + + You must enter a number! + Wpisz liczbe! - - Select one or more video files to download subtitles for - Wybierz jeden lub więcej plików z filmami + + You must enter a number between %1 and %2 + Wprowadz liczbe miedzy %1 a %2 - QNapiCli + DontShowListArgParser - - Invalid language code: %1 - Niepoprawny kod jezykowy: %1 + + Never show a list of available subtitles + Nie pokazuj listy dostępnych napisów + + + ExtensionArgParser - - Invalid target subtitles format: %1 - Niepoprawny format napisów: %1 + + You need to pass subtitles extension after %1 argument + Należy podać rozszerzenie napisów po argumencie %1 - - File not found! - Nie znaleziono pliku! + + Invalid target subtitles extension passed: %1 + Podano niepoprawne rozszerzenie napisow: %1 - - Path to the program p7zip is incorrect! Check your settings. - Sciezka do programu p7zip jest nieprawidlowa! Sprawdz swoje ustawienia. + + ext + ext - - Can not write to the temporary directory! Check your settings. - Nie można pisac do katalogu tymczasowego! Sprawdz swoje ustawienia. + + Select target subtitles file extension + Rozszerzenie pliku z napisami + + + FormatArgParser - - * Downloading subtitles for '%1' - * Pobieranie napisow dla '%1' + + You need to pass subtitles format code after %1 argument + Należy podać format napisów po argumencie %1 - - No permission to write to the directory '%1'! - Brak uprawnien zapisu do katalogu '%1'! + + Invalid target subtitles format passed: %1 + Podano niepoprawny format napisow: %1 - - Calculating checksums... - Obliczanie sum kontrolnych... + + format + format - - - Searching for subtitles [%1] (%2)... - Szukanie napisow [%1] (%2)... + + Select target subtitles file format (one of mDVD, MPL2, SRT, TMP) + Docelowy format napisów (mDVD, MPL2, SRT, TMP) + + + GetThread - - - Searching for subtitles in alternative language [%1] (%2)... - Szukanie napisow w jezyku zapasowym [%1] (%2)... + + Checking permissions of the video directory... + Sprawdzanie uprawnień do katalogu z filmem... - - Subtitles not found! - Nie znaleziono napisow! + + No permission to write to the directory '%1'! + Brak uprawnień zapisu do katalogu '%1'! - - 0) Do not download subtitles for this video - 0) Nie pobieraj napisow dla tego filmu + + Calculating checksum of the file... + Obliczanie sumy kontrolnej pliku... - - Found subtitles: - Znaleziono napisy: + + + Searching for subtitles [%1] (%2)... + Szukanie napisów [%1] (%2)... - - (good) - (dobre) + + + Searching for subtitles in alternative language [%1] (%2)... + Szukanie napisów w języku zapasowym [%1] (%2)... - - (bad) - (zle) + + Downloading subtitles file... + Pobieranie napisów dla pliku... - - Select subtitles to download: - Wybierz napisy do pobrania: + + Unpacking subtitles file... + Rozpakowywanie napisów... - - You must enter a number! - Wpisz liczbe! + + Post-processing subtitles... + Przetwarzanie napisów... - - Enter a number from the list! - Wpisz liczbe z listy! + + Adjusting subtitles... + Dopasowywanie napisów... - - Downloading subtitles... - Pobieranie napisow z serwera... + + Could not adjust subtitles! + Nie udało się dopasować napisów! + + + GuiMain - - Unable to download subtitles! - Nie udalo sie pobrac napisow! + + List of languages recognized by QNapi, including corresponding + Oto lista rozpoznawanych przez QNapi jezykow i odpowiadajacym - - Unpacking subtitles... - Rozpakowywanie napisow... + + two-letter language codes: + im dwuliterowych kodow: - - Failed to unpack subtitles! - Nie udało sie poprawnie rozpakowac napisow! + + Current default subtitles language: %1 (%2) + Aktualnie ustawiony preferowany jezyk pobierania napisow: %1 (%2) - - Post-processing subtitles file... - Przetwarzanie pobranych napisow... + + No alternative subtitles language has been set + Brak ustawionego zapasowego jezyka napisow - - Adjusting subtitles... - Dopasowywanie napisow... + + Current alternative subtitles language: %1 (%2) + Aktualnie ustawiony zapasowy jezyk napisow: %1 (%2) - - Could not adjust subtitles! - Nie udalo sie dopasowac napisow! + + QNapi - command line argument parsing error + QNapi - błąd parsowania argumentu wiersza poleceń - - QNapi %1, %2 - QNapi %1, %2 + + QNapi - CLI executable not found + QNapi - nie znaleziono wersji dla wiersza poleceń - - Qt version: %1 - wersja Qt: %1 + + You have requested to run QNapi in command-line mode, but unfortunately command-line binary '%1' could not be found. + Zażądano uruchomienia QNapi w trybie wiersza poleceń, jednak nie znaleziono '%1'. + + + HelpHelper - + QNapi is distributed under the GNU General Public License v2. QNapi rozprowadzany jest na warunkach licencji GNU General Public License v2. - - any messages or windows (implies -d) - ani nie pokazujac zadnych okien (implikuje -d) + + Syntax: %1 [options] [list of files] + Skladnia: %1 [opcje] [lista plikow] - - -d, --dont-show-list Do not show a list of subtitles (works only with -c) - -d, --dont-show-list Nie pokazuj listy napisow (dziala tylko z -c) + + Available options: + Dostepne opcje: + + + LangArgParser - - -l, --lang [code] Preferred subtitles language - -l, --lang [jezyk] Preferowany jezyk napisow + + You need to pass language code after %1 argument + Musisz podac kod jezyka po argumencie %1 - - -lb,--lang-backup [code] Alternative subtitles language - -lb,--lang-backup [jezyk] Zapasowy jezyk napisow + + Invalid language code passed: %1 + Niepoprawny kod jezykowy: %1 - - -o, --options Show program options (only GUI) - -o, --options Konfiguruj program (tylko w trybie GUI) + + code + kod - - -hl,--help-languages List of available subtitles languages - -hl,--help-languages Lista jezykow, w jakich mozna pobierac napisy + + Preferred subtitles language + Preferowany język napisów + + + MaiaObject - - two-letter language codes: - im dwuliterowych kodow: + + parse error: invalid xml-rpc. not conforming to spec. + błąd parsowania: niepoprawny xml-rpc. niezgodny ze specyfikacją. + + + QNapiApp - - Current default subtitles language: %1 (%2) - Aktualnie ustawiony preferowany jezyk pobierania napisow: %1 (%2) + + + + + Download subtitles + Pobierz napisy - - Syntax: %1 [options] [list of files] - Skladnia: %1 [opcje] [lista plikow] + + Scan directories + Skanuj katalogi - - Available options: - Dostepne opcje: + + Convert subtitles + Konwertuj napisy - - -c, --console Download subtitles with console - -c, --console Pobierz napisy w trybie wiersza polecen + + + + Create an account + Załóż konto - - -q, --quiet Download subtitles quietly without showing - -q, --quiet Pobierz napisy nie wypisujac zadnych komunikatow + + Upload subtitles + Wyślij napisy - - -s, --show-list Show a list of subtitles (works only with -c) - -s, --show-list Pokazuj liste napisow (dziala tylko z -c) + + Settings + Ustawienia - - -f, --format [format] Select target subtitles file format (%1) - -f, --format [format] Format napisow (%1) + + About + O programie - - -e, --extension [ext] Select target subtitles file extension - -e, --extension [ext] Rozszerzenie pliku z napisami + + Quit + Zakończ - - -h, --help Show help text - -h, --help Pokaz tekst pomocy + + NapiProjekt + NapiProjekt - - List of languages recognized by QNapi, including corresponding - Oto lista rozpoznawanych przez QNapi jezykow i odpowiadajacym + + OpenSubtitles + OpenSubtitles - - No alternative subtitles language has been set - Brak ustawionego zapasowego jezyka napisow + + Napisy24 + Napisy24 - - Current alternative subtitles language: %1 (%2) - Aktualnie ustawiony zapasowy jezyk napisow: %1 (%2) + + Select one or more video files to download subtitles for + Wybierz jeden lub więcej plików z filmami QNapiOpenDialog - + Video files (%1);;All files (*.*) Filmy (%1);;Wszystkie pliki (*.*) - + Subtitles files (%1);;All files (*.*) Napisy (%1);;Wszystkie pliki (*.*) @@ -388,7 +484,7 @@ QObject - + <b>www.napiprojekt.pl</b> subtitles download engine Silnik pobierania napisów z serwisu <b>www.napiprojekt.pl</b> @@ -398,230 +494,270 @@ Silnik pobierania napisów z serwisu <b>www.napisy24.pl</b> - + <b>www.opensubtitles.org</b> subtitles download engine Silnik pobierania napisów z serwisu <b>www.opensubtitles.org</b> - + First Run Pierwsze uruchomienie - + This is the first launch of the program QNapi. Do you want to configure it now? To jest pierwsze uruchomienie programu QNapi. Czy chcesz przeprowadzić konfigurację teraz? - + QNapi: deleting temporary files... QNapi: usuwanie plików tymczasowych... - + QNapi: finished. QNapi: zakończono. - + No subtitles found! Nie znaleziono napisów! - + Subtitles downloaded and processed by QNapi| Napisy pobrane i przetworzone programem QNapi| - + Albanian Albański - + English Angielski - + Arabic Arabski - + Bulgarian Bułgarski - + Chinese Chiński - + Croatian Chorwacki - + Czech Czeski - + Danish Duński - + Estonian Estoński - + Finnish Fiński - + French Francuski - + Galician Galicyjski - + Greek Grecki - + Hebrew Hebrajski - + Spanish Hiszpanski - + Dutch Holenderski - + Indonesian Indonezyjski - + Japanese Japoński - + Korean Koreański - + Macedonian Macedoński - + German Niemiecki - + Norwegian Norweski - + Occitan Oksytański - + Persian (farsi) Perski (farsi) - + Polish Polski - + Portuguese Portugalski - + Portuguese-BR Portugalski-BR - + Russian Rosyjski - + Romanian Rumuński - + Serbian Serbski - + Slovenian Słoweński - + Swedish Szwedzki - + Slovak Słowacki - + Turkish Turecki - + Vietnamese Wietnamski - + Hungarian Węgierski - + Italian Włoski + + QuietBatchArgParser + + + Download subtitles silently without showing any messages + Pobierz napisy nie wypisujac zadnych komunikatow (implikuje -d) + + + + RunCLIAppArgParser + + + Run in command-line mode (requires separate CLI binary) + Uruchom w trybie wiersza poleceń (wymaga osobnego pliku wykonywalnego) + + + + ShowHelpArgParser + + + Show help text + Pokaż tekst pomocy + + + + ShowHelpLanguagesArgParser + + + List of available subtitles languages + Pokaż dostępne języki pobierania napisów + + + + ShowListArgParser + + + Always show a list of available subtitles + Zawsze pokazuj listę dostępnych napisów + + SubtitleMatcher - + _copy _kopia @@ -634,37 +770,32 @@ QNapi - O programie - + <html><head/><body><p>QNapi is a program for automatic downloading and matching subtitles for movies. </p><p>The program is distributed under the GNU General Public License version second or later.</p><p><a href="http://qnapi.github.io"><span style=" text-decoration: underline; color:#0000ff;">http://qnapi.github.io</span></a></p><p>I thank all those who in any way supported the development of the project.</p></body></html> <html><head/><body><p>QNapi jest programem do automatycznego pobierania i dopasowywania napisów do filmów. </p><p>Program rozprowadzany jest na licencji GNU General Public License w wersji drugiej lub późniejszej.</p><p><a href="http://qnapi.github.io"><span style=" text-decoration: underline; color:#0000ff;">http://qnapi.github.io</span></a></p><p>Dziękuję wszystkim osobom, które w jakikolwiek sposób wsparły rozwój projektu.</p></body></html> - + Qt version: x.y.z Wersja Qt: x.y.z - + The program uses www.napiprojekt.pl subtitle database Program korzysta z bazy napisów www.napiprojekt.pl - + The program uses www.opensubtitles.org subtitle database Program korzysta z bazy napisów www.opensubtitles.org - + The program uses www.napisy24.pl subtitle database Program korzysta z bazy napisów www.napisy24.pl - - Close - Zamknij - - - + QNapi version Wersja QNapi @@ -821,43 +952,43 @@ Konwertuj - + Choose a subtitles file Wybierz plik z napisami - + incorrect niepoprawny - + Default (%1) Domyślne (%1) - - + + Select a video file Wybierz plik z filmem - + Subtitles converted Przekonwertowano napisy - + Changed subtitles format from '%1' to '%2' Poprawnie zmieniono format napisów z '%1' na '%2' - + An error occured while converting subtitles! Wystąpił problem podczas zamiany formatu napisów! - + Could not change subtitle format! Problem podczas konwertowania napisów! @@ -895,17 +1026,17 @@ Na czerwono podświetlono napisy <b>prawdopodobnie</b> niepasujące do Twojego filmu. - + Select the subtitles which you want to download for video file<br><br><b>%1</b> Z poniższej listy wybierz napisy, które chcesz dopasować do pliku<br><br><b>%1</b> - + No subtitle selected Nie wybrano napisów - + You need to select a subtitle from the list! Musisz wybrać napisy z listy! @@ -1073,7 +1204,7 @@ - + Auto-detected based on system language (%1) Wykryty automatycznie z ustawień systemu (%1) @@ -1143,7 +1274,7 @@ Move down - Przesuń na dół + Przesuń na dół @@ -1228,7 +1359,7 @@ - + Default Domyślne @@ -1263,17 +1394,17 @@ Zapisz - + Specify the path for 7z executable Wskaż ścieżkę do programu 7z - + Invalid path Niepoprawna ścieżka - + Defined path to 7z executable is invalid. If you can not locate 7z executable, try installing p7zip-full package. "Wskazana przez Ciebie ścieżka do programu 7z jest niepoprawna. Jeśli nie możesz odnaleźć programu 7z, spróbuj zainstalować pakiet p7zip-full. @@ -1283,22 +1414,22 @@ Wskaż katalog tymczasowy - + Warning Ostrzeżenie - + At least one subtitles engine must remain active! Przynajmniej jeden moduł pobierania musi pozostać aktywny! - + %1 subtitles engine info Informacje o module pobierania napisów %1 - + Default (%1) Domyślne (%1) @@ -1321,62 +1452,62 @@ Anuluj - + Can not find p7zip! Brak programu p7zip! - + The path to the program p7zip is incorrect! Ścieżka do programu p7zip jest nieprawidłowa! - + Invalid temporary directory! Nieprawidłowy katalog tymczasowy! - + Unable to write to the temporary directory! Check your settings. Nie można pisać do katalogu tymczasowego! Sprawdź swoje ustawienia. - + No files! Brak plików! - + Can't download subtitles as no movie files specified! Nie wskazano filmów do pobrania napisów! - + QNapi - downloading subtitles (%1/%2) QNapi - pobieranie napisów (%1/%2) - + QNapi - downloading subtitles... QNapi - pobieranie napisów... - + Critical error! Błąd krytyczny! - + QNapi QNapi - + Do you want to cancel subtitles downloading? Czy chcesz przerwać pobieranie napisów? - + Finishing the tasks... Kończenie zadań... @@ -1395,7 +1526,7 @@ - + Scan Skanuj @@ -1451,7 +1582,7 @@ - + Cancel Anuluj @@ -1466,32 +1597,32 @@ Podążaj za dowiązaniami symbolicznymi - + Select the folder to scan Wskaż katalog do skanowania - + Scanning directories... Skanowanie katalogów... - + Interrupting directory scanning... Przerywanie skanowania katalogów... - + Scanning directory <b>%1</b>... Skanowanie katalogu <b>%1</b>... - + Select the videos you wish to download subtitles for. Zaznacz filmy, do których chcesz pobrać napisy. - + No video files found. Nie znaleziono plików z filmami. @@ -1519,24 +1650,24 @@ OK - + Subtitles downloaded for %1 %2 Pobrano napisy dla %1 %2 - + files plików - + file pliku - + Could not download subtitles for %1 %2 Nie pobrano napisów dla %1 %2