Skip to content

Commit

Permalink
Add support for new EPG tag attributes: credits (actors, writers, dir…
Browse files Browse the repository at this point in the history
…ectors), categories, year.
  • Loading branch information
ksooo committed Nov 6, 2017
1 parent d5554db commit 54e246d
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 9 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(HTS_SOURCES_TVHEADEND_ENTITY
src/tvheadend/entity/Channel.h
src/tvheadend/entity/Entity.h
src/tvheadend/entity/Event.h
src/tvheadend/entity/Event.cpp
src/tvheadend/entity/Recording.h
src/tvheadend/entity/RecordingBase.h
src/tvheadend/entity/RecordingBase.cpp
Expand Down
67 changes: 60 additions & 7 deletions src/Tvheadend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1344,15 +1344,23 @@ void CTvheadend::CreateEvent
epg.strPlotOutline = event.GetSummary().c_str();
epg.strPlot = event.GetDesc().c_str();
epg.strOriginalTitle = NULL; /* not supported by tvh */
epg.strCast = NULL; /* not supported by tvh */
epg.strDirector = NULL; /* not supported by tvh */
epg.strWriter = NULL; /* not supported by tvh */
epg.iYear = 0; /* not supported by tvh */
epg.strCast = event.GetCast().c_str();
epg.strDirector = event.GetDirectors().c_str();
epg.strWriter = event.GetWriters().c_str();
epg.iYear = event.GetYear();
epg.strIMDBNumber = NULL; /* not supported by tvh */
epg.strIconPath = event.GetImage().c_str();
epg.iGenreType = event.GetGenreType();
epg.iGenreSubType = event.GetGenreSubType();
epg.strGenreDescription = NULL; /* not supported by tvh */
if (epg.iGenreType == 0)
{
const std::string& categories = event.GetCategories();
if (!categories.empty())
{
epg.iGenreType = EPG_GENRE_USE_STRING;
epg.strGenreDescription = categories.c_str();
}
}
epg.firstAired = event.GetAired();
epg.iParentalRating = event.GetAge();
epg.iStarRating = event.GetStars();
Expand Down Expand Up @@ -2449,11 +2457,56 @@ bool CTvheadend::ParseEvent ( htsmsg_t *msg, bool bAdd, Event &evt )
evt.SetPart(u32);
if ((str = htsmsg_get_str(msg, "serieslinkUri")) != NULL)
evt.SetSeriesLink(str);

/* Add optional recording link */
if (!htsmsg_get_u32(msg, "copyrightYear", &u32))
evt.SetYear(u32);
if (!htsmsg_get_u32(msg, "dvrId", &u32))
evt.SetRecordingId(u32);

htsmsg_t *l;
if ((l = htsmsg_get_map(msg, "credits")) != nullptr)
{
std::vector<std::string> writers;
std::vector<std::string> directors;
std::vector<std::string> cast;

htsmsg_field_t *f;
HTSMSG_FOREACH(f, l)
{
if (f->hmf_name == nullptr)
continue;

const char *str = htsmsg_field_get_string(f);
if (str == nullptr)
continue;

if (!strcmp(str, "writer"))
writers.emplace_back(f->hmf_name);
else if (!strcmp(str, "director"))
directors.emplace_back(f->hmf_name);
else if (!strcmp(str, "actor") || !strcmp(str, "guest") || !strcmp(str, "presenter"))
cast.emplace_back(f->hmf_name);
}

evt.SetWriters(writers);
evt.SetDirectors(directors);
evt.SetCast(cast);
}

if ((l = htsmsg_get_list(msg, "category")) != nullptr)
{
std::vector<std::string> categories;

htsmsg_field_t *f;
HTSMSG_FOREACH(f, l)
{
const char *str = f->hmf_str;
if (str != nullptr)
categories.emplace_back(str);
}

evt.SetCategories(categories);
}

return true;
}

Expand Down
47 changes: 47 additions & 0 deletions src/tvheadend/entity/Event.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2017 Team Kodi
* http://kodi.tv
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XBMC; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/

#include "Event.h"

#include "p8-platform/util/StringUtils.h"
#include "xbmc_epg_types.h"

using namespace tvheadend::entity;

void Event::SetWriters(const std::vector<std::string> &writers)
{
m_writers = StringUtils::Join(writers, EPG_STRING_TOKEN_SEPARATOR);
}

void Event::SetDirectors(const std::vector<std::string> &directors)
{
m_directors = StringUtils::Join(directors, EPG_STRING_TOKEN_SEPARATOR);
}

void Event::SetCast(const std::vector<std::string> &cast)
{
m_cast = StringUtils::Join(cast, EPG_STRING_TOKEN_SEPARATOR);
}

void Event::SetCategories(const std::vector<std::string> &categories)
{
m_categories = StringUtils::Join(categories, EPG_STRING_TOKEN_SEPARATOR);
}
31 changes: 29 additions & 2 deletions src/tvheadend/entity/Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "Entity.h"
#include <map>
#include <vector>
#include <cstdint>
#include <string>

Expand Down Expand Up @@ -52,7 +53,8 @@ namespace tvheadend
m_season(0),
m_episode(0),
m_part(0),
m_recordingId(0)
m_recordingId(0),
m_year(0)
{
}

Expand All @@ -76,7 +78,12 @@ namespace tvheadend
m_summary == other.m_summary &&
m_image == other.m_image &&
m_recordingId == other.m_recordingId &&
m_seriesLink == other.m_seriesLink;
m_seriesLink == other.m_seriesLink &&
m_year == other.m_year &&
m_writers == other.m_writers &&
m_directors == other.m_directors &&
m_cast == other.m_cast &&
m_categories == other.m_categories;
}

bool operator!=(const Event &other) const
Expand Down Expand Up @@ -141,6 +148,21 @@ namespace tvheadend
const std::string& GetSeriesLink() const { return m_seriesLink; }
void SetSeriesLink(const std::string &seriesLink) { m_seriesLink = seriesLink; }

uint32_t GetYear() const { return m_year; }
void SetYear(uint32_t year) { m_year = year; }

const std::string& GetWriters() const { return m_writers; }
void SetWriters(const std::vector<std::string> &writers);

const std::string& GetDirectors() const { return m_directors; }
void SetDirectors(const std::vector<std::string> &directors);

const std::string& GetCast() const { return m_cast; }
void SetCast(const std::vector<std::string> &cast);

const std::string& GetCategories() const { return m_categories; }
void SetCategories(const std::vector<std::string> &categories);

private:
uint32_t m_next;
uint32_t m_channel;
Expand All @@ -160,6 +182,11 @@ namespace tvheadend
std::string m_image;
uint32_t m_recordingId;
std::string m_seriesLink;
uint32_t m_year;
std::string m_writers;
std::string m_directors;
std::string m_cast;
std::string m_categories;
};
}
}

0 comments on commit 54e246d

Please sign in to comment.