From 23f9f7712bfa33b5a488a447a6fabe6035cc3240 Mon Sep 17 00:00:00 2001 From: chriszero Date: Sat, 15 Nov 2014 19:43:07 +0100 Subject: initial commit --- .gitignore | 6 + Config.cpp | 86 +++ Config.h | 80 +++ ControlServer.cpp | 17 + ControlServer.h | 37 ++ Directory.cpp | 34 ++ Directory.h | 51 ++ Makefile | 193 +++++++ Media.cpp | 54 ++ Media.h | 62 ++ MediaContainer.cpp | 46 ++ MediaContainer.h | 63 +++ PVideo.cpp | 59 ++ PVideo.h | 67 +++ PlexHTTPRequestHandler.cpp | 182 ++++++ PlexHTTPRequestHandler.h | 63 +++ PlexHelper.cpp | 16 + PlexHelper.h | 17 + PlexReqHandlerFactory.cpp | 33 ++ PlexReqHandlerFactory.h | 28 + PlexServer.cpp | 41 ++ PlexServer.h | 81 +++ Plexservice.cpp | 205 +++++++ Plexservice.h | 65 +++ SubscriptionManager.cpp | 118 ++++ SubscriptionManager.h | 79 +++ XmlObject.cpp | 87 +++ XmlObject.h | 34 ++ cPlexOsdItem.cpp | 34 ++ cPlexOsdItem.h | 39 ++ misc.h | 157 ++++++ play_service.h | 31 + player.c | 984 ++++++++++++++++++++++++++++++++ player.h | 160 ++++++ plex.cpp | 1335 ++++++++++++++++++++++++++++++++++++++++++++ plex.h | 222 ++++++++ plexgdm.cpp | 130 +++++ plexgdm.h | 75 +++ user.cpp | 31 + user.h | 42 ++ video.c | 775 +++++++++++++++++++++++++ video.h | 62 ++ 42 files changed, 5981 insertions(+) create mode 100644 Config.cpp create mode 100644 Config.h create mode 100644 ControlServer.cpp create mode 100644 ControlServer.h create mode 100644 Directory.cpp create mode 100644 Directory.h create mode 100644 Makefile create mode 100644 Media.cpp create mode 100644 Media.h create mode 100644 MediaContainer.cpp create mode 100644 MediaContainer.h create mode 100644 PVideo.cpp create mode 100644 PVideo.h create mode 100644 PlexHTTPRequestHandler.cpp create mode 100644 PlexHTTPRequestHandler.h create mode 100644 PlexHelper.cpp create mode 100644 PlexHelper.h create mode 100644 PlexReqHandlerFactory.cpp create mode 100644 PlexReqHandlerFactory.h create mode 100644 PlexServer.cpp create mode 100644 PlexServer.h create mode 100644 Plexservice.cpp create mode 100644 Plexservice.h create mode 100644 SubscriptionManager.cpp create mode 100644 SubscriptionManager.h create mode 100644 XmlObject.cpp create mode 100644 XmlObject.h create mode 100644 cPlexOsdItem.cpp create mode 100644 cPlexOsdItem.h create mode 100644 misc.h create mode 100644 play_service.h create mode 100644 player.c create mode 100644 player.h create mode 100644 plex.cpp create mode 100644 plex.h create mode 100644 plexgdm.cpp create mode 100644 plexgdm.h create mode 100644 user.cpp create mode 100644 user.h create mode 100644 video.c create mode 100644 video.h diff --git a/.gitignore b/.gitignore index b8bd026..8bd4302 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,9 @@ *.exe *.out *.app + +# Other files +.dependencies +*.pot +*.project +*~ diff --git a/Config.cpp b/Config.cpp new file mode 100644 index 0000000..ff4b721 --- /dev/null +++ b/Config.cpp @@ -0,0 +1,86 @@ +#include "Config.h" + + +std::string Config::GetUUID() { + if(s_uuid.empty()) { + using Poco::UUIDGenerator; + using Poco::UUID; + UUIDGenerator &generator = UUIDGenerator::defaultGenerator(); + UUID uuid(generator.createRandom()); + s_uuid = uuid.toString(); + } + return s_uuid; +} + +void Config::SetUUID(const char* uuid) { + if (uuid) s_uuid = std::string(uuid); +} + + +std::string Config::GetHostname() { + if(s_hostname.empty()) { + char hostname[1024]; + gethostname(hostname, 1024); + s_hostname = std::string(hostname); + } + return s_hostname; +} + +std::string Config::GetLanguage() { + return "de"; +} + +std::string Config::GetUsername() { + return s_username; +} + +std::string Config::GetPassword() { + return s_password; +} + +////////////////////////////////////////////////////////////////////////////// +// cMenuSetupPage +////////////////////////////////////////////////////////////////////////////// + +/** +** Process key for setup menu. +*/ +eOSState cMyMenuSetupPage::ProcessKey(eKeys key) +{ + return cMenuSetupPage::ProcessKey(key); +} + +/** +** Constructor setup menu. +** +** Import global config variables into setup. +*/ +cMyMenuSetupPage::cMyMenuSetupPage(void) +{ + strn0cpy(Username, Config::GetInstance().s_username.c_str(), STRING_SIZE); + strn0cpy(Password, Config::GetInstance().s_password.c_str(), STRING_SIZE); + strn0cpy(Uuid, Config::GetInstance().GetUUID().c_str(), STRING_SIZE); + + Add(new cMenuEditBoolItem(tr("Hide main menu entry"), (int*)&Config::GetInstance().HideMainMenuEntry, trVDR("no"), trVDR("yes"))); + Add(new cMenuEditBoolItem(tr("Disable remote"), (int*)&Config::GetInstance().DisableRemote, trVDR("no"), trVDR("yes"))); + Add(new cMenuEditStrItem(tr("Plex Username"), Username, STRING_SIZE)); + Add(new cMenuEditStrItem(tr("Plex Password"), Password, STRING_SIZE)); + cMenuEditStrItem* devUUID = new cMenuEditStrItem(tr("Current UUID"), Uuid, STRING_SIZE); + devUUID->SetSelectable(false); + Add(devUUID); +} + +/** +** Store setup. +*/ +void cMyMenuSetupPage::Store(void) +{ + Config::GetInstance().s_username = std::string(Username); + Config::GetInstance().s_password = std::string(Password); + + SetupStore("HideMainMenuEntry", Config::GetInstance().HideMainMenuEntry); + SetupStore("DisableRemote", Config::GetInstance().DisableRemote); + SetupStore("Username", Config::GetInstance().s_username.c_str()); + SetupStore("Password", Config::GetInstance().s_password.c_str()); + SetupStore("UUID", Config::GetInstance().GetUUID().c_str()); +} \ No newline at end of file diff --git a/Config.h b/Config.h new file mode 100644 index 0000000..3bc805a --- /dev/null +++ b/Config.h @@ -0,0 +1,80 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#include +#include +#include + +#include +#include +#include + +//VDR +#include +#include + + + +/// vdr-plugin version number. +/// Makefile extracts the version number for generating the file name +/// for the distribution archive. +static const char *const VERSION = "0.0.1" +#ifdef GIT_REV + "-GIT" GIT_REV +#endif + ; + +#define STRING_SIZE 256 + +class Config +{ + +public: + static Config& GetInstance() { + static Config instance; + return instance; + } + + std::string s_username = "username"; + std::string s_password = "password"; + + bool HideMainMenuEntry; + bool DisableRemote; + + std::string GetUUID(); + void SetUUID(const char* uuid); + std::string GetHostname(); + std::string GetLanguage(); + std::string GetUsername(); + std::string GetPassword(); + + +private: + Config() {} + std::string s_uuid; + std::string s_hostname; +}; + + +////////////////////////////////////////////////////////////////////////////// +// cMenuSetupPage +////////////////////////////////////////////////////////////////////////////// + +/** +** Play plugin menu setup page class. +*/ +class cMyMenuSetupPage:public cMenuSetupPage +{ + protected: + char Username[STRING_SIZE]; + char Password[STRING_SIZE]; + char Uuid[STRING_SIZE]; + + virtual void Store(void); + + public: + cMyMenuSetupPage(void); + virtual eOSState ProcessKey(eKeys); // handle input +}; + +#endif // CONFIG_H diff --git a/ControlServer.cpp b/ControlServer.cpp new file mode 100644 index 0000000..439dc7a --- /dev/null +++ b/ControlServer.cpp @@ -0,0 +1,17 @@ +#include "ControlServer.h" + +namespace plexclient +{ + +void ControlServer::Start() { + // start the HTTPServer + m_pSrv->start(); +} + +void ControlServer::Stop() { + // Stop the HTTPServer + m_pSrv->stop(); +} + + +} diff --git a/ControlServer.h b/ControlServer.h new file mode 100644 index 0000000..55f8299 --- /dev/null +++ b/ControlServer.h @@ -0,0 +1,37 @@ +#ifndef CONTROLSERVER_H +#define CONTROLSERVER_H + +#include +#include +#include +#include +#include + +#include "PlexHTTPRequestHandler.h" +#include "PlexReqHandlerFactory.h" + +namespace plexclient +{ + +class ControlServer +{ + +public: + static ControlServer& GetInstance() { + static ControlServer instance; + return instance; + } + void Start(); + void Stop(); + +private: + ControlServer() {}; + + Poco::Net::ServerSocket *m_pSvs = new Poco::Net::ServerSocket(3200);; + Poco::Net::HTTPServer *m_pSrv = new Poco::Net::HTTPServer(new PlexReqHandlerFactory, *m_pSvs, new Poco::Net::HTTPServerParams); + +}; + +} + +#endif // CONTROLSERVER_H diff --git a/Directory.cpp b/Directory.cpp new file mode 100644 index 0000000..c54580f --- /dev/null +++ b/Directory.cpp @@ -0,0 +1,34 @@ +#include "Directory.h" + +namespace plexclient +{ + +Directory::Directory(Poco::XML::Node* pNode) +{ + if(Poco::icompare(pNode->nodeName(), "Directory") == 0) { + + Poco::XML::AutoPtr pAttribs = pNode->attributes(); + + m_bAllowSync = GetNodeValueAsBool(pAttribs->getNamedItem("allowSync")); + 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_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(); + } +} + +Directory::~Directory() +{ +} + + +} + diff --git a/Directory.h b/Directory.h new file mode 100644 index 0000000..fb54bc5 --- /dev/null +++ b/Directory.h @@ -0,0 +1,51 @@ +#ifndef DIRECTORY_H +#define DIRECTORY_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "XmlObject.h" + +using Poco::XML::DOMParser; +using Poco::XML::Document; +using Poco::XML::NodeIterator; +using Poco::XML::NodeFilter; +using Poco::XML::Node; +using Poco::XML::AutoPtr; +using Poco::Exception; + +namespace plexclient +{ + +class Directory: XmlObject +{ +public: + Directory(Poco::XML::Node* pNode); + ~Directory(); + +public: + bool m_bAllowSync; + std::string m_sTitle; + std::string m_sComposite; + std::string m_sLanguage; + std::string m_sUuid; + std::string m_sArt; + std::string m_sThumb; + Poco::Timestamp m_tUpdatedAt; + Poco::Timestamp m_tCreatedAt; + std::string m_sKey; + MediaType m_eType; + +}; + +} + + +#endif // DIRECTORY_H diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1344831 --- /dev/null +++ b/Makefile @@ -0,0 +1,193 @@ +# +# Makefile for a Video Disk Recorder plugin +# +# $Id: ac85bc689caa43a6c25d7e0573733b36fab6167e $ + +# The official name of this plugin. +# This name will be used in the '-P...' option of VDR to load the plugin. +# By default the main source file also carries this name. + +PLUGIN = plex + +LIBS += -lPocoUtil -lPocoNet -lPocoNetSSL -lPocoXML -lPocoFoundation + +### Configuration (edit this for your needs) + + # support avfs a virtual file system +# FIXME: AVFS isn't working, corrupts memory +#AVFS ?= $(shell test -x /usr/bin/avfs-config && echo 1) + # use ffmpeg libswscale +SWSCALE ?= $(shell pkg-config --exists libswscale && echo 1) + # support png images +PNG ?= $(shell pkg-config --exists libpng && echo 1) + # support jpg images +JPG ?= $(shell test -r /usr/include/jpeglib.h && echo 1) + +CONFIG := #-DDEBUG # uncomment to build DEBUG + +ifeq ($(AVFS),1) +CONFIG += -DUSE_AVFS +_CFLAGS += $(shell /usr/bin/avfs-config --cflags) +LIBS += $(shell /usr/bin/avfs-config --libs) +endif +ifeq ($(SWSCALE),1) +CONFIG += -DUSE_SWSCALE +_CFLAGS += $(shell pkg-config --cflags libswscale) +LIBS += $(shell pkg-config --libs libswscale) +endif +ifeq ($(PNG),1) +CONFIG += -DUSE_PNG +_CFLAGS += $(shell pkg-config --cflags libpng) +LIBS += $(shell pkg-config --libs libpng) +endif +ifeq ($(JPG),1) +CONFIG += -DUSE_JPG +_CFLAGS += -I/usr/include +LIBS += -Ljpeg + +endif + + +_CFLAGS += $(shell pkg-config --cflags xcb xcb-image xcb-keysyms xcb-icccm) +LIBS += -lrt $(shell pkg-config --libs xcb xcb-image xcb-keysyms xcb-icccm) + +### The version number of this plugin (taken from the main source file): + +VERSION = $(shell grep 'static const char \*const VERSION *=' $(PLUGIN).cpp | awk '{ print $$7 }' | sed -e 's/[";]//g') +GIT_REV = $(shell git describe --always 2>/dev/null) + +### The directory environment: + +# Use package data if installed...otherwise assume we're under the VDR source directory: +PKGCFG = $(if $(VDRDIR),$(shell pkg-config --variable=$(1) $(VDRDIR)/vdr.pc),$(shell pkg-config --variable=$(1) vdr || pkg-config --variable=$(1) ../../../vdr.pc)) +LIBDIR = $(call PKGCFG,libdir) +LOCDIR = $(call PKGCFG,locdir) +PLGCFG = $(call PKGCFG,plgcfg) +# +TMPDIR ?= /tmp + +### The compiler options: + +export CFLAGS = $(call PKGCFG,cflags) +export CXXFLAGS = $(call PKGCFG,cxxflags) + +CXXFLAGS += -std=gnu++0x -Wunused-variable -Wunused-parameter + +ifeq ($(CFLAGS),) +$(error CFLAGS not set) +endif +ifeq ($(CXXFLAGS),) +$(error CXXFLAGS not set) +endif + +### The version number of VDR's plugin API: + +APIVERSION = $(call PKGCFG,apiversion) + +### Allow user defined options to overwrite defaults: + +-include $(PLGCFG) + +### The name of the distribution archive: + +ARCHIVE = $(PLUGIN)-$(VERSION) +PACKAGE = vdr-$(ARCHIVE) + +### The name of the shared object file: + +SOFILE = libvdr-$(PLUGIN).so + +### Includes and Defines (add further entries here): + +INCLUDES += + +DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \ + $(if $(GIT_REV), -DGIT_REV='"$(GIT_REV)"') + +### Make it standard + +override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \ + -g -W -Wall -Wextra -Winit-self -Werror=overloaded-virtual +override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \ + -g -W -Wall -Wextra -Winit-self -Wdeclaration-after-statement + +### The object files (add further files here): + +OBJS = $(patsubst %.c,%.o,$(wildcard *.c)) +OBJS += $(patsubst %.cpp,%.o,$(wildcard *.cpp)) + +SRCS = $(wildcard $(OBJS:.o=.c)) $(PLUGIN).cpp + +### The main target: + +all: $(SOFILE) i18n + +### Dependencies: + +MAKEDEP = $(CXX) -MM -MG +DEPFILE = .dependencies +$(DEPFILE): Makefile + @$(MAKEDEP) $(CXXFLAGS) $(SRCS) > $@ + +-include $(DEPFILE) + +### Internationalization (I18N): + +PODIR = po +I18Npo = $(wildcard $(PODIR)/*.po) +I18Nmo = $(addsuffix .mo, $(foreach file, $(I18Npo), $(basename $(file)))) +I18Nmsgs = $(addprefix $(DESTDIR)$(LOCDIR)/, $(addsuffix /LC_MESSAGES/vdr-$(PLUGIN).mo, $(notdir $(foreach file, $(I18Npo), $(basename $(file)))))) +I18Npot = $(PODIR)/$(PLUGIN).pot + +%.mo: %.po + msgfmt -c -o $@ $< + +$(I18Npot): $(SRCS) + xgettext -C -cTRANSLATORS --no-wrap --no-location -k -ktr -ktrNOOP --package-name=vdr-$(PLUGIN) --package-version=$(VERSION) --msgid-bugs-address='' -o $@ `ls $^` + +%.po: $(I18Npot) + msgmerge -U --no-wrap --no-location --backup=none -q -N $@ $< + @touch $@ + +$(I18Nmsgs): $(DESTDIR)$(LOCDIR)/%/LC_MESSAGES/vdr-$(PLUGIN).mo: $(PODIR)/%.mo + install -D -m644 $< $@ + +.PHONY: i18n +i18n: $(I18Nmo) $(I18Npot) + +install-i18n: $(I18Nmsgs) + +### Targets: + +$(OBJS): Makefile + +$(SOFILE): $(OBJS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@ + +install-lib: $(SOFILE) + install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION) + +install: install-lib install-i18n + +dist: $(I18Npo) clean + @-rm -rf $(TMPDIR)/$(ARCHIVE) + @mkdir $(TMPDIR)/$(ARCHIVE) + @cp -a * $(TMPDIR)/$(ARCHIVE) + @tar czf $(PACKAGE).tgz -C $(TMPDIR) $(ARCHIVE) + @-rm -rf $(TMPDIR)/$(ARCHIVE) + @echo Distribution package created as $(PACKAGE).tgz + +clean: + @-rm -f $(PODIR)/*.mo $(PODIR)/*.pot + @-rm -f $(OBJS) $(DEPFILE) *.so *.tgz core* *~ + +## Private Targets: + +HDRS= $(wildcard *.h) + +indent: + for i in $(SRCS) $(HDRS); do \ + indent $$i; \ + unexpand -a $$i | sed -e s/constconst/const/ > $$i.up; \ + mv $$i.up $$i; \ + done diff --git a/Media.cpp b/Media.cpp new file mode 100644 index 0000000..d3c53a2 --- /dev/null +++ b/Media.cpp @@ -0,0 +1,54 @@ +#include "Media.h" + +namespace plexclient +{ + +Media::Media(Poco::XML::Node* pNode) +{ + NodeIterator it(pNode, Poco::XML::NodeFilter::SHOW_ALL); + Poco::XML::Node* pChildNode = it.nextNode(); + + while(pChildNode) { + if(Poco::icompare(pChildNode->nodeName(), "Media") == 0) { + + Poco::XML::AutoPtr pAttribs = pChildNode->attributes(); + m_sVideoResolution = GetNodeValue(pAttribs->getNamedItem("videoResolution")); + m_iId = GetNodeValueAsInt(pAttribs->getNamedItem("id")); + m_lDuration = GetNodeValueAsLong(pAttribs->getNamedItem("duration")); + m_iBitrate = GetNodeValueAsInt(pAttribs->getNamedItem("bitrate")); + m_iWidth = GetNodeValueAsInt(pAttribs->getNamedItem("width")); + m_iHeight = GetNodeValueAsInt(pAttribs->getNamedItem("height")); + m_sAspectRatio = GetNodeValue(pAttribs->getNamedItem("aspectRatio")); + m_iAudioChannels = GetNodeValueAsInt(pAttribs->getNamedItem("audioChannels")); + m_sAudioCodec = GetNodeValue(pAttribs->getNamedItem("audioCodec")); + m_sVideoCodec = GetNodeValue(pAttribs->getNamedItem("videoCodec")); + m_sContainer = GetNodeValue(pAttribs->getNamedItem("container")); + m_sVideoFrameRate = GetNodeValue(pAttribs->getNamedItem("videoFrameRate")); + + + pAttribs->release(); + + } + if(Poco::icompare(pChildNode->nodeName(), "Part") == 0) { + + Poco::XML::AutoPtr pAttribs = pChildNode->attributes(); + m_sPartKey = GetNodeValue(pAttribs->getNamedItem("key")); + m_iPartId = GetNodeValueAsInt(pAttribs->getNamedItem("id")); + m_lPartDuration = GetNodeValueAsLong(pAttribs->getNamedItem("duration")); + m_sPartFile = GetNodeValue(pAttribs->getNamedItem("file")); + m_lPartSize = GetNodeValueAsLong(pAttribs->getNamedItem("size")); + m_sPartContainer = GetNodeValue(pAttribs->getNamedItem("container")); + + pAttribs->release(); + } + pChildNode = it.nextNode(); + } +} + +Media::~Media() +{ +} + + +} + diff --git a/Media.h b/Media.h new file mode 100644 index 0000000..f2394cd --- /dev/null +++ b/Media.h @@ -0,0 +1,62 @@ +#ifndef MEDIA_H +#define MEDIA_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "XmlObject.h" // Base class: model::XmlObject + +using Poco::XML::DOMParser; +using Poco::XML::Document; +using Poco::XML::NodeIterator; +using Poco::XML::NodeFilter; +using Poco::XML::Node; +using Poco::XML::AutoPtr; +using Poco::Exception; + +namespace plexclient +{ + +class Media: XmlObject +{ +public: + Media(Poco::XML::Node* pNode); + ~Media(); + +public: + std::string m_sVideoResolution; + int m_iId; + long m_lDuration; + int m_iBitrate; + int m_iWidth; + int m_iHeight; + std::string m_sAspectRatio; + int m_iAudioChannels; + std::string m_sAudioCodec; + std::string m_sVideoCodec; + std::string m_sContainer; + std::string m_sVideoFrameRate; + + std::string m_sPartKey; + int m_iPartId; + long m_lPartDuration; + std::string m_sPartFile; + long m_lPartSize; + std::string m_sPartContainer; + +}; + +} + +#endif // MEDIA_H diff --git a/MediaContainer.cpp b/MediaContainer.cpp new file mode 100644 index 0000000..08b386f --- /dev/null +++ b/MediaContainer.cpp @@ -0,0 +1,46 @@ +#include "MediaContainer.h" + +namespace plexclient +{ +MediaContainer::MediaContainer(std::istream* response) +{ + try { + InputSource src(*response); + DOMParser parser; + Poco::XML::AutoPtr pDoc = parser.parse(&src); + + NodeIterator it(pDoc, Poco::XML::NodeFilter::SHOW_ALL); + Poco::XML::Node* pNode = it.nextNode(); + + while(pNode) { + if(Poco::icompare(pNode->nodeName(), "MediaContainer") == 0) { + Poco::XML::NamedNodeMap* pAttribs = pNode->attributes(); + + m_sTitle = GetNodeValue(pAttribs->getNamedItem("title1")); + m_sTitle2 = GetNodeValue(pAttribs->getNamedItem("title2")); + m_sThumb = GetNodeValue(pAttribs->getNamedItem("thumb")); + m_sViewGroup = GetNodeValue(pAttribs->getNamedItem("viewGroup")); + m_sLibrarySectionTitle = GetNodeValue(pAttribs->getNamedItem("librarySectionTitle")); + m_sLibrarySectionUUID = GetNodeValue(pAttribs->getNamedItem("librarySectionUUID")); + m_iLibrarySectionID = GetNodeValueAsInt(pAttribs->getNamedItem("librarySectionID")); + m_sMediaTagPrefix = GetNodeValue(pAttribs->getNamedItem("mediaTagPrefix")); + m_iSize = GetNodeValueAsInt(pAttribs->getNamedItem("size")); + m_bAllowSync = GetNodeValueAsBool(pAttribs->getNamedItem("allowSync")); + m_sArt = GetNodeValue(pAttribs->getNamedItem("art")); + + pAttribs->release(); + } else if(Poco::icompare(pNode->nodeName(), "Directory") == 0) { + m_vDirectories.push_back(Directory(pNode)); + } else if(Poco::icompare(pNode->nodeName(), "Video") == 0) { + m_vVideos.push_back(Video(pNode)); + } + + pNode = it.nextNode(); + } + + } catch(Exception &exc) { + std::cerr << exc.displayText() << std::endl; + } +} + +} diff --git a/MediaContainer.h b/MediaContainer.h new file mode 100644 index 0000000..2633086 --- /dev/null +++ b/MediaContainer.h @@ -0,0 +1,63 @@ +#ifndef ALLSECTIONS_H +#define ALLSECTIONS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "XmlObject.h" +#include "Directory.h" +#include "PVideo.h" + +using Poco::XML::DOMParser; +using Poco::XML::InputSource; +using Poco::XML::Document; +using Poco::XML::NodeIterator; +using Poco::XML::NodeFilter; +using Poco::XML::Node; +using Poco::XML::AutoPtr; +using Poco::Exception; + +namespace plexclient +{ + +class MediaContainer: XmlObject +{ +public: + MediaContainer(std::istream *response); + + ~MediaContainer(); + +protected: + + +public: + std::vector m_vDirectories; + std::vector