summaryrefslogtreecommitdiff
path: root/Directory.cpp
blob: e62714ffa1b9a69d064345f62823ef3a3693a6ff (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
#include "Directory.h"
#include <vdr/i18n.h>
#include <Poco/Format.h>

namespace plexclient
{

Directory::Directory(Poco::XML::Node* pNode, PlexServer* Server, MediaContainer* parent)
{
	m_pServer = Server;
	if(Poco::icompare(pNode->nodeName(), "Directory") == 0) {
		Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pNode->attributes();

		m_bAllowSync = GetNodeValueAsBool(pAttribs->getNamedItem("allowSync"));
		m_iIndex = GetNodeValueAsInt(pAttribs->getNamedItem("index"));
		m_iYear = GetNodeValueAsInt(pAttribs->getNamedItem("year"));
		m_sArt = GetNodeValue(pAttribs->getNamedItem("art"));
		m_sThumb = GetNodeValue(pAttribs->getNamedItem("thumb"));
		m_sKey = GetNodeValue(pAttribs->getNamedItem("key"));
		m_sTitle = GetNodeValue(pAttribs->getNamedItem("title"));
		m_sTitle1 = GetNodeValue(pAttribs->getNamedItem("title1"));
		m_sTitle2 = GetNodeValue(pAttribs->getNamedItem("title2"));
		m_sComposite = GetNodeValue(pAttribs->getNamedItem("composite"));
		m_sLanguage = GetNodeValue(pAttribs->getNamedItem("language"));
		m_sUuid = GetNodeValue(pAttribs->getNamedItem("uuid"));
		m_tUpdatedAt = GetNodeValueAsTimeStamp(pAttribs->getNamedItem("updatedAt"));
		m_tCreatedAt = GetNodeValueAsTimeStamp(pAttribs->getNamedItem("createdAt"));
		m_eType = GetNodeValueAsMediaType(pAttribs->getNamedItem("type"));

		pAttribs->release();
	}
	if(m_sTitle2.empty()) m_sTitle2 = parent->m_sTitle2;
}

std::string Directory::GetTitle()
{
	switch(m_eType) {
	case SEASON:
		return Poco::format(tr("%s - Season %d"), m_sTitle2, m_iIndex);
	default:
		return m_sTitle;
	}
}

void Directory::AddTokens(std::shared_ptr<cOsdElement> grid, bool clear, std::function<void(cGridElement*)> OnCached)
{
	if(clear) grid->ClearTokens();
	grid->AddStringToken("title", m_sTitle);
}

}