-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Prepare for central MovieScrapeJob class
Split movie scrapers into scrape jobs. That way we can run them in parallel, have better preview windows, etc. This commit does not implement them, but prepares the file structure. I do this to avoid future changes in the result-parsing, that may be accidentally reverted once this feature is implemented (due to my feature branch not being up to date or having merge conflicts).
- Loading branch information
Showing
41 changed files
with
1,582 additions
and
949 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ third_party/packaging_win | |
|
||
# Deployment | ||
create-dmg/ | ||
tmp/ | ||
|
||
# OS specific | ||
.directory | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "scrapers/movie/MovieScrapeJob.h" | ||
|
||
#include "data/movie/Movie.h" | ||
|
||
namespace mediaelch { | ||
namespace scraper { | ||
|
||
MovieScrapeJob::MovieScrapeJob(MovieScrapeJob::Config config, QObject* parent) : | ||
worker::Job(parent), m_movie{new Movie({}, this)}, m_config{std::move(config)} | ||
{ | ||
// Wrapper to avoid static_assert calls. | ||
connect(this, &Job::finished, this, [this]() { emit loadFinished(this, QPrivateSignal{}); }); | ||
|
||
// TODO: Change to true / remove once all usages of MovieScrapeJob are updated. | ||
setAutoDelete(false); | ||
} | ||
|
||
const ScraperError& MovieScrapeJob::scraperError() const | ||
{ | ||
return m_scraperError; | ||
} | ||
|
||
void MovieScrapeJob::setScraperError(ScraperError error) | ||
{ | ||
m_scraperError = std::move(error); | ||
setError(static_cast<int>(m_scraperError.error)); | ||
setErrorString(m_scraperError.message); | ||
setErrorText(m_scraperError.technical); | ||
} | ||
|
||
} // namespace scraper | ||
} // namespace mediaelch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#pragma once | ||
|
||
#include "data/Locale.h" | ||
#include "scrapers/ScraperError.h" | ||
#include "scrapers/ScraperInfos.h" | ||
#include "scrapers/movie/MovieIdentifier.h" | ||
#include "utils/Meta.h" | ||
#include "workers/Job.h" | ||
|
||
#include <QObject> | ||
|
||
class Movie; | ||
|
||
namespace mediaelch { | ||
namespace scraper { | ||
|
||
/// \todo Currently not used properly; only used as a base for future changes. | ||
class MovieScrapeJob : public worker::Job | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
/// \brief Configuration object for a movie scrape job. | ||
struct Config | ||
{ | ||
/// \brief A string that can be consumed by the movie scraper. | ||
/// \details It is used to uniquely identify the movie. May be an IMDb ID in | ||
/// string representation or an URL. | ||
MovieIdentifier identifier; | ||
/// \brief Language key for the scraper, e.g. "en-US", "de-DE", ... | ||
Locale locale = Locale::English; | ||
/// \brief movie details to be loaded using the scraper. | ||
QSet<MovieScraperInfo> details; | ||
}; | ||
|
||
public: | ||
MovieScrapeJob(Config config, QObject* parent = nullptr); | ||
~MovieScrapeJob() override = default; | ||
|
||
public: | ||
ELCH_NODISCARD Movie& movie() { return *m_movie; } | ||
ELCH_NODISCARD const Movie& movie() const { return *m_movie; } | ||
|
||
ELCH_NODISCARD const Config& config() const { return m_config; } | ||
ELCH_NODISCARD const ScraperError& scraperError() const; | ||
|
||
signals: | ||
/// \brief Signal emitted when the scrape job has finished. | ||
/// \details A simple wrapper around finished() to avoid static_asserts | ||
/// from Job* to ShowSearchJob*. | ||
/// Use hasError() and movie() to know whether the request was successful. | ||
void loadFinished(mediaelch::scraper::MovieScrapeJob* scrapeJob, QPrivateSignal); | ||
|
||
protected: | ||
void setScraperError(ScraperError error); | ||
|
||
protected: | ||
Movie* m_movie = nullptr; | ||
|
||
private: | ||
const Config m_config; | ||
ScraperError m_scraperError; | ||
}; | ||
|
||
} // namespace scraper | ||
} // namespace mediaelch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.