Example #1
0
def out_schedule ( xml, sched, channel ):

  # Output broadcasts
  ele = Element('schedule', channel=channel.uri)
  for b in sched:
    out_broadcast(ele, b)
  xml.addChild(ele)
Example #2
0
def out_channel(xml, chn):
    ele = Element("channel", id=chn.uri)
    ele.addChild(Element("name", chn.title))
    if chn.image:
        ele.addChild(Element("image", chn.image))
    if chn.radio:
        ele.addChild(Element("radio"))
    # TODO: extra metadata
    xml.addChild(ele)
Example #3
0
def out_episode ( xml, eps ):
  ele = Element('episode', id=eps.uri)
  if eps.brand:
    ele.addAttribute('brand', eps.brand.uri)
  if eps.series:
    ele.addAttribute('series', eps.series.uri)
  # TODO: re-think this!
  ele.addChild(Element('title', eps.get_title()))
  st = eps.get_subtitle()
  if st:
    ele.addChild(Element('subtitle', st))
  su = eps.get_summary()
  if su:
    ele.addChild(Element('summary', su))
  if eps.number:
    ele.addChild(Element('number', eps.number))
  if eps.part_num:
    ele.addChild(Element('part-number', eps.part_num))
  if eps.part_cnt:
    ele.addChild(Element('part-count', eps.part_cnt))
  if eps.film:
    ele.addChild(Element('film'))
  for g in eps.get_genres():
    ele.addChild(Element('genre', g))
  cs = eps.get_credits()
  if cs:
    cre = Element('credits')
    for r in cs:
      for p in cs[r]:
        if p.role == 'actor' and p.character:
          cre.addChild(Element('actor', p.name, character=p.character))
        else:
          cre.addChild(Element(r, p.name))
    ele.addChild(cre)
  if eps.year and eps.film:
    ele.addChild(Element('date', eps.year))
  if eps.baw:
    ele.addChild(Element('blackandwhite'))

  # TODO: images
  #if eps.image:
  #  ele.addChild(Element('image', eps.image))
  #if eps.thumb:
  #  ele.addChild(Element('thumb', eps.thumb))

  # TODO: HD (as in showing on HD channel)

  xml.addChild(ele)
Example #4
0
def out_series ( xml, series ):
  ele = Element('series', id=series.uri)
  if series.brand:
    ele.addAttribute('brand', series.brand.uri)
  if series.title:
    ele.addChild(Element('title', series.title))
  if series.summary:
    ele.addChild(Element('summary', series.summary))
  if series.image:
    ele.addChild(Element('image', series.image))
  if series.thumb:
    ele.addChild(Element('thumb', series.thumb))
  if series.number is not None:
    ele.addChild(Element('number', series.number))
  else:
    log.warn('no series number for %s' % series.uri)
  if series.episode_count:
    ele.addChild(Element('episode_count', series.episode_count))
  xml.addChild(ele)
Example #5
0
def out_brand ( xml, brand ):
  ele = Element('brand', id=brand.uri)
  if brand.title:
    ele.addChild(Element('title', brand.title))
  if brand.summary:
    ele.addChild(Element('summary', brand.summary))
  if brand.series_count:
    ele.addChild(Element('series_count', brand.series_count))
  if brand.image:
    ele.addChild(Element('image', brand.image))
  if brand.thumb:
    ele.addChild(Element('thumb', brand.thumb))
  xml.addChild(ele)
Example #6
0
def out_channel ( xml, chn ):
  ele = Element('channel', id=chn.uri)
  ele.addChild(Element('name', chn.title))
  if chn.image:
    ele.addChild(Element('image', chn.image))
  if chn.radio:
    ele.addChild(Element('radio'))
  # TODO: extra metadata
  xml.addChild(ele)
Example #7
0
def out_broadcast ( xml, bcast ):
  f   = bcast.start.strftime(PYEPG_TIME_FORMAT)
  t   = bcast.stop.strftime(PYEPG_TIME_FORMAT)

  ele = Element('broadcast', episode=bcast.episode.uri, start=f, stop=t)

  if bcast.hd:
    ele.addChild(Element('hd'))
  if bcast.widescreen or bcast.hd:
    ele.addChild(Element('widescreen'))
  # TODO: quality and aspect ratio
  if bcast.new:
    ele.addChild(Element('new'))
  if bcast.premiere:
    ele.addChild(Element('premiere'))
  if bcast.repeat:
    ele.addChild(Element('repeat'))
  if bcast.subtitled:
    ele.addChild(Element('subtitles', type='teletext'))
  if bcast.signed:
    ele.addChild(Element('subtitles', type='deaf-signed'))
  # TODO: audio described
  # TODO: certification and ratings
  # TODO: image

  xml.addChild(ele)
Example #8
0
def out_episode ( xml, e, extended = False ):
  s   = e
  e   = s.episode
  t1  = s.start.strftime(XMLTV_TIME_FORMAT)
  t2  = s.stop.strftime(XMLTV_TIME_FORMAT)
  ele = Element('programme', start=t1, stop=t2, channel=s.channel.uri)

  # Extended attributes
  if extended:
    ele.addChild(Element('uri', e.uri))
    if e.brand is not None:
      ele.addChild(Element('brand-uri', e.brand.uri))
    if e.series is not None:
      ele.addChild(Element('season-uri', e.series.uri))

  # Title/Sub-title
  t  = e.get_title()
  st = e.get_subtitle()
  if t:
    ele.addChild(Element('title', t, lang='en'))
  if st:
    ele.addChild(Element('sub-title', st, lang='en'))

  # Description
  d = e.get_summary()
  if d:
    ele.addChild(Element('desc', d, lang='en'))

  # Credits
  credits = e.get_credits()
  if credits:
    cre = Element('credits')
    for r in [ 'director', 'presenter', 'actor', 'commentator', 'guest' ]:
      if r in credits:
        for p in credits[r]:
          cre.addChild(Element(r, p.name, lang='en'))
    ele.addChild(cre)

  # Date
  if e.year is not None:
    ele.addChild(Element('date', e.year))

  # Genres
  for g in e.get_genres():
    ele.addChild(Element('category', g))

  # Episode number
  if extended:
    en = ec = sn = sc = pn = pc = 0
    if e.brand  and e.brand.series_count is not None:
      sc = e.brand.series_count
    if e.series and e.series.number is not None:
      sn = e.series.number
    if e.series and e.series.episode_count is not None:
      ec = e.series.episode_count
    if e.number is not None:
      en = e.number
    if e.part_num is not None:
      pn = e.part_num
    if e.part_cnt is not None:
      pc = e.part_cnt
    if en or sn or pn:
      cdata = '%d/%d.%d/%d.%d/%d' % (sn, sc, en, ec, pn, pc)
      ele.addChild(Element('episode-num', cdata, system='pyepg'))
  else:
    n = e.get_number()
    if n:
      ns = n[0]
      if ns is None: ns = 0
      else: ns = ns - 1
      ne = n[1] - 1
      cdata = '%d.%d.0' % (ns, ne)
      ele.addChild(Element('episode-num', cdata, system='xmltv_ns'))

  # Video metadata
  vid = Element('video')
  if e.baw:
    vid.addChild(Element('colour', 'no'))
  if s.aspect is not None:
    vid.addChild(Element('aspect', s.aspect))
  elif s.widescreen or s.hd:
    vid.addChild(Element('aspect', '16:9'))
  if s.hd:
    vid.addChild(Element('quality', 'HDTV'))
  else:
    vid.addChild(Element('quality', 'SDTV'))
  if extended and s.lines:
    vid.addChild(Element('lines', s.lines))
  ele.addChild(vid)

  # History
  if s.repeat:
    ele.addChild(Element('previously-shown'))
  if s.premiere:
    ele.addChild(Element('premiere'))
  if s.new:
    ele.addChild(Element('new'))

  # Hearing / Visually impaired
  if s.subtitled:
    ele.addChild(Element('subtitles', type='teletext'))
  if s.signed:
    ele.addChild(Element('subtitles', type='deaf-signed'))
  if s.audio_desc and extended:
    ele.addChild(Element('audio-described'))

  # TODO: Certification

  # TODO: Ratings

  # Done
  xml.addChild(ele)
Example #9
0
def out_channel ( xml, c, extended = False ):
  ele = Element('channel', id=c.uri)
  ele.addChild(Element('display-name', c.title, lang='en'))
  if c.image:
    ele.addChild(Element('icon', src=c.image))
  xml.addChild(ele)
Example #10
0
def out_episode(xml, eps):
    ele = Element("episode", id=eps.uri)
    if eps.brand:
        ele.addAttribute("brand", eps.brand.uri)
    if eps.series:
        ele.addAttribute("series", eps.series.uri)
    # TODO: re-think this!
    ele.addChild(Element("title", eps.get_title()))
    st = eps.get_subtitle()
    if st:
        ele.addChild(Element("subtitle", st))
    su = eps.get_summary()
    if su:
        ele.addChild(Element("summary", su))
    if eps.number:
        ele.addChild(Element("number", eps.number))
    if eps.part_num:
        ele.addChild(Element("part-number", eps.part_num))
    if eps.part_cnt:
        ele.addChild(Element("part-count", eps.part_cnt))
    if eps.film:
        ele.addChild(Element("film"))
    for g in eps.get_genres():
        ele.addChild(Element("genre", g))
    cs = eps.get_credits()
    if cs:
        cre = Element("credits")
        for r in cs:
            for p in cs[r]:
                if p.role == "actor" and p.character:
                    cre.addChild(Element("actor", p.name, character=p.character))
                else:
                    cre.addChild(Element(r, p.name))
        ele.addChild(cre)
    if eps.year and eps.film:
        ele.addChild(Element("date", eps.year))
    if eps.baw:
        ele.addChild(Element("blackandwhite"))

    # TODO: images
    # if eps.image:
    #  ele.addChild(Element('image', eps.image))
    # if eps.thumb:
    #  ele.addChild(Element('thumb', eps.thumb))

    # TODO: HD (as in showing on HD channel)

    xml.addChild(ele)
Example #11
0
def out_series(xml, series):
    ele = Element("series", id=series.uri)
    if series.brand:
        ele.addAttribute("brand", series.brand.uri)
    if series.title:
        ele.addChild(Element("title", series.title))
    if series.summary:
        ele.addChild(Element("summary", series.summary))
    if series.image:
        ele.addChild(Element("image", series.image))
    if series.thumb:
        ele.addChild(Element("thumb", series.thumb))
    if series.number is not None:
        ele.addChild(Element("number", series.number))
    else:
        log.warn("no series number for %s" % series.uri)
    if series.episode_count:
        ele.addChild(Element("episode_count", series.episode_count))
    xml.addChild(ele)
Example #12
0
def out_brand(xml, brand):
    ele = Element("brand", id=brand.uri)
    if brand.title:
        ele.addChild(Element("title", brand.title))
    if brand.summary:
        ele.addChild(Element("summary", brand.summary))
    if brand.series_count:
        ele.addChild(Element("series_count", brand.series_count))
    if brand.image:
        ele.addChild(Element("image", brand.image))
    if brand.thumb:
        ele.addChild(Element("thumb", brand.thumb))
    xml.addChild(ele)
Example #13
0
def out_broadcast(xml, bcast):
    f = bcast.start.strftime(PYEPG_TIME_FORMAT)
    t = bcast.stop.strftime(PYEPG_TIME_FORMAT)

    ele = Element("broadcast", episode=bcast.episode.uri, start=f, stop=t)

    if bcast.hd:
        ele.addChild(Element("hd"))
    if bcast.widescreen or bcast.hd:
        ele.addChild(Element("widescreen"))
    # TODO: quality and aspect ratio
    if bcast.new:
        ele.addChild(Element("new"))
    if bcast.premiere:
        ele.addChild(Element("premiere"))
    if bcast.repeat:
        ele.addChild(Element("repeat"))
    if bcast.subtitled:
        ele.addChild(Element("subtitles", type="teletext"))
    if bcast.signed:
        ele.addChild(Element("subtitles", type="deaf-signed"))
    # TODO: audio described
    # TODO: certification and ratings
    # TODO: image

    xml.addChild(ele)
Example #14
0
def out_episode(xml, e, extended=False):
    s = e
    e = s.episode
    t1 = s.start.strftime(XMLTV_TIME_FORMAT)
    t2 = s.stop.strftime(XMLTV_TIME_FORMAT)
    ele = Element('programme', start=t1, stop=t2, channel=s.channel.uri)

    # Extended attributes
    if extended:
        ele.addChild(Element('uri', e.uri))
        if e.brand is not None:
            ele.addChild(Element('brand-uri', e.brand.uri))
        if e.series is not None:
            ele.addChild(Element('season-uri', e.series.uri))

    # Title/Sub-title
    t = e.get_title()
    st = e.get_subtitle()
    if t:
        ele.addChild(Element('title', t, lang='en'))
    if st:
        ele.addChild(Element('sub-title', st, lang='en'))

    # Description
    d = e.get_summary()
    if d:
        ele.addChild(Element('desc', d, lang='en'))

    # Credits
    credits = e.get_credits()
    if credits:
        cre = Element('credits')
        for r in ['director', 'presenter', 'actor', 'commentator', 'guest']:
            if r in credits:
                for p in credits[r]:
                    cre.addChild(Element(r, p.name, lang='en'))
        ele.addChild(cre)

    # Date
    if e.year is not None:
        ele.addChild(Element('date', e.year))

    # Genres
    for g in e.get_genres():
        ele.addChild(Element('category', g))

    # Episode number
    if extended:
        en = ec = sn = sc = pn = pc = 0
        if e.brand and e.brand.series_count is not None:
            sc = e.brand.series_count
        if e.series and e.series.number is not None:
            sn = e.series.number
        if e.series and e.series.episode_count is not None:
            ec = e.series.episode_count
        if e.number is not None:
            en = e.number
        if e.part_num is not None:
            pn = e.part_num
        if e.part_cnt is not None:
            pc = e.part_cnt
        if en or sn or pn:
            cdata = '%d/%d.%d/%d.%d/%d' % (sn, sc, en, ec, pn, pc)
            ele.addChild(Element('episode-num', cdata, system='pyepg'))
    else:
        n = e.get_number()
        if n:
            ns = n[0]
            if ns is None: ns = 0
            else: ns = ns - 1
            ne = n[1] - 1
            cdata = '%d.%d.0' % (ns, ne)
            ele.addChild(Element('episode-num', cdata, system='xmltv_ns'))

    # Video metadata
    vid = Element('video')
    if e.baw:
        vid.addChild(Element('colour', 'no'))
    if s.aspect is not None:
        vid.addChild(Element('aspect', s.aspect))
    elif s.widescreen or s.hd:
        vid.addChild(Element('aspect', '16:9'))
    if s.hd:
        vid.addChild(Element('quality', 'HDTV'))
    else:
        vid.addChild(Element('quality', 'SDTV'))
    if extended and s.lines:
        vid.addChild(Element('lines', s.lines))
    ele.addChild(vid)

    # History
    if s.repeat:
        ele.addChild(Element('previously-shown'))
    if s.premiere:
        ele.addChild(Element('premiere'))
    if s.new:
        ele.addChild(Element('new'))

    # Hearing / Visually impaired
    if s.subtitled:
        ele.addChild(Element('subtitles', type='teletext'))
    if s.signed:
        ele.addChild(Element('subtitles', type='deaf-signed'))
    if s.audio_desc and extended:
        ele.addChild(Element('audio-described'))

    # TODO: Certification

    # TODO: Ratings

    # Done
    xml.addChild(ele)
Example #15
0
def out_channel(xml, c, extended=False):
    ele = Element('channel', id=c.uri)
    ele.addChild(Element('display-name', c.title, lang='en'))
    if c.image:
        ele.addChild(Element('icon', src=c.image))
    xml.addChild(ele)