blob: fcab5768c64c9b2da216801255bc4e90d4b96121 (
plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
* Copyright (C) 2005-2018 Team Kodi
* This file is part of Kodi - https://kodi.tv
*
* SPDX-License-Identifier: GPL-2.0-or-later
* See LICENSES/README.md for more information.
*/
#pragma once
#include "MusicAlbumInfo.h"
#include "MusicArtistInfo.h"
#include "addons/Scraper.h"
#include "threads/Thread.h"
#include <vector>
namespace XFILE
{
class CurlFile;
}
namespace MUSIC_GRABBER
{
class CMusicInfoScraper : public CThread
{
public:
explicit CMusicInfoScraper(const ADDON::ScraperPtr &scraper);
~CMusicInfoScraper(void) override;
void FindAlbumInfo(const std::string& strAlbum, const std::string& strArtist = "");
void LoadAlbumInfo(int iAlbum);
void FindArtistInfo(const std::string& strArtist);
void LoadArtistInfo(int iArtist, const std::string &strSearch);
bool Completed();
bool Succeeded();
void Cancel();
bool IsCanceled();
int GetAlbumCount() const;
int GetArtistCount() const;
CMusicAlbumInfo& GetAlbum(int iAlbum);
CMusicArtistInfo& GetArtist(int iArtist);
std::vector<CMusicArtistInfo>& GetArtists()
{
return m_vecArtists;
}
std::vector<CMusicAlbumInfo>& GetAlbums()
{
return m_vecAlbums;
}
void SetScraperInfo(const ADDON::ScraperPtr& scraper)
{
m_scraper = scraper;
}
/*!
\brief Checks whether we have a valid scraper. If not, we try the fallbackScraper
First tests the current scraper for validity by loading it. If it is not valid we
attempt to load the fallback scraper. If this is also invalid we return false.
\param fallbackScraper name of scraper to use as a fallback
\return true if we have a valid scraper (or the default is valid).
*/
bool CheckValidOrFallback(const std::string &fallbackScraper);
protected:
void FindAlbumInfo();
void LoadAlbumInfo();
void FindArtistInfo();
void LoadArtistInfo();
void OnStartup() override;
void Process() override;
std::vector<CMusicAlbumInfo> m_vecAlbums;
std::vector<CMusicArtistInfo> m_vecArtists;
std::string m_strAlbum;
std::string m_strArtist;
std::string m_strSearch;
int m_iAlbum;
int m_iArtist;
bool m_bSucceeded;
bool m_bCanceled;
XFILE::CCurlFile* m_http;
ADDON::ScraperPtr m_scraper;
};
}
|