-
Notifications
You must be signed in to change notification settings - Fork 0
/
csfddetailservice.cpp
61 lines (47 loc) · 1.87 KB
/
csfddetailservice.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "csfddetailservice.h"
#include <QProcess>
CsfdDetailService::CsfdDetailService(TorrentSqlTableModel *const model)
: AbstractMovieDetailService(model)
, m_movieScrapperPath(getMovieScrapperPath())
{}
SearchMovieResult CsfdDetailService::searchMovieDetail(const QSqlRecord &torrent) const
{
// TODO handle errors in std::cerr silverqx
QProcess movieScrapper;
QStringList arguments;
arguments << m_movieScrapperPath
<< QStringLiteral("csfd-search")
<< prepareSearchQueryString(torrent);
movieScrapper.start(QStringLiteral("node.exe"), arguments);
// TODO check all paths, when obtaining movie detail was not successful silverqx
if (!movieScrapper.waitForStarted())
return {};
if (!movieScrapper.waitForFinished())
return {};
const auto movieDetailRaw = movieScrapper.readAll();
qDebug() << "Searched movie detail obtained from čsfd.cz";
return parseSearchedMovieDetail(movieDetailRaw);
}
MovieDetailResult CsfdDetailService::obtainMovieDetail(const quint64 filmId) const
{
// TODO handle errors in std::cerr silverqx
QProcess movieScrapper;
QStringList arguments;
arguments << m_movieScrapperPath
<< QStringLiteral("csfd-get")
<< QString::number(filmId);
movieScrapper.start(QStringLiteral("node.exe"), arguments);
// TODO check all paths, when obtaining movie detail was not successful silverqx
if (!movieScrapper.waitForStarted())
return {};
if (!movieScrapper.waitForFinished())
return {};
const auto movieDetailRaw = movieScrapper.readAll();
qDebug() << "Obtained movie detail obtained from čsfd.cz";
return parseMovieDetail(movieDetailRaw);
}
QString CsfdDetailService::getMovieDetailColumnName() const noexcept
{
static const auto cached = QStringLiteral("csfd_movie_detail");
return cached;
}