[mythtv-commits] Ticket #13028: Patch - xmltvparser.cpp choose first valid icon

MythTV noreply at mythtv.org
Wed Apr 19 00:44:59 UTC 2017


#13028: Patch - xmltvparser.cpp choose first valid icon
-------------------------------------------------+-------------------------
     Reporter:  Gary Buhrmaster                  |      Owner:  stuartm
  <gary.buhrmaster@…>                            |
         Type:  Patch - Bug Fix                  |     Status:  new
     Priority:  minor                            |  Milestone:  unknown
    Component:  MythTV - Mythfilldatabase        |    Version:  Master Head
     Severity:  medium                           |   Keywords:
Ticket locked:  0                                |
-------------------------------------------------+-------------------------
 [Cleaning up some old local stashes regarding compliance validation to try
 to not lose something that someone might find useful at some future point]

 The xmltv dtd specifies that a channel can have multiple icons, and while
 the dtd is not explicit regarding the icon, for the station url, the most
 authoritative should be first, which is likely the intended order for
 icons too.

 AFAIK no grabber currently returns multiple icons (although there are some
 EPG sources that now provide them), but MythTV appears to choose the last
 provided in the xml file for a station (which is likely not what is
 desirable).

 This proposed patch changes MythTV to use the first valid icon if multiple
 are provided.

 To the dev who reviews the patch, the patch is a bit ugly due to git diff
 (sorry about that), but essentially just wraps the icon assignment inside
 a "isEmpty()" check, so only the first valid icon provided will be used.

 Untested (Caveat Emptor) [I compiled it at one point in the past, but I do
 not recall creating a test dataset]


 {{{
 diff --git a/mythtv/programs/mythfilldatabase/xmltvparser.cpp
 b/mythtv/programs/mythfilldatabase/xmltvparser.cpp
 index f3249ce..efb6dba 100644
 --- a/mythtv/programs/mythfilldatabase/xmltvparser.cpp
 +++ b/mythtv/programs/mythfilldatabase/xmltvparser.cpp
 @@ -89,18 +89,21 @@ ChannelInfo *XMLTVParser::parseChannel(QDomElement
 &element, QUrl &baseUrl)
          {
              if (info.tagName() == "icon")
              {
 -                QString path = info.attribute("src", "");
 -                if (!path.isEmpty() && !path.contains("://"))
 +                if (chaninfo->icon.isEmpty())
                  {
 -                    QString base =
 baseUrl.toString(QUrl::StripTrailingSlash);
 -                    chaninfo->icon = base +
 -                        ((path.startsWith("/")) ? path : QString("/") +
 path);
 -                }
 -                else if (!path.isEmpty())
 -                {
 -                    QUrl url(path);
 -                    if (url.isValid())
 -                        chaninfo->icon = url.toString();
 +                    QString path = info.attribute("src", "");
 +                    if (!path.isEmpty() && !path.contains("://"))
 +                    {
 +                        QString base =
 baseUrl.toString(QUrl::StripTrailingSlash);
 +                        chaninfo->icon = base +
 +                            ((path.startsWith("/")) ? path : QString("/")
 + path);
 +                    }
 +                    else if (!path.isEmpty())
 +                    {
 +                        QUrl url(path);
 +                        if (url.isValid())
 +                            chaninfo->icon = url.toString();
 +                    }
                  }
              }
              else if (info.tagName() == "display-name")
 }}}

--
Ticket URL: <https://code.mythtv.org/trac/ticket/13028>
MythTV <http://www.mythtv.org>
MythTV Media Center


More information about the mythtv-commits mailing list