python-xmltv

A Python Module for Reading and Writing XMLTV Files
Download

python-xmltv Ranking & Summary

Advertisement

  • Rating:
  • License:
  • LGPL v3
  • Price:
  • FREE
  • Publisher Name:
  • James Oakley
  • Publisher web site:
  • http://bitbucket.org/jfunk/

python-xmltv Tags


python-xmltv Description

]python-xmltv is a Python library that provides access to XMLTV data. XMLTV is an XML format for storing TV listings.More information on XMLTV can be found at http://membled.com/work/apps/xmltv/UsageUsage of the module is generally straight-forward:: import xmltv from pprint import pprint # If you need to change the locale: # xmltv.locale = 'Latin-1' # If you need to change the date format used in the XMLTV file: # xmltv.date_format = '%Y%m%d%H%M%S %Z' filename = '/path/to/xmltv/file' # Print info for XMLTV file (source, etc.) pprint(xmltv.read_data(open(filename, 'r'))) # Print channels pprint(xmltv.read_channels(open(filename, 'r'))) # Print programmes pprint(xmltv.read_programmes(open(filename, 'r')))There are currently three functions for reading that should be used: **read_data** ``(file_object) -> dict`` Get the source and other info from an XMLTV file. Returns a dictionary of attributes, eg:: {'date': u'20030702230041 -0300', 'generator-info-name': u'tv_grab_na V3.20030629', 'generator-info-url': u'', 'source-info-name': u'Zap2It', 'source-info-url': u'http://www.zap2it.com'} **read_channels** ``(file_object) -> list`` Get all of the channels. Returns a list of hashes, each representing a channel, eg: , 'id': u'C10eltv.zap2it.com'}, {'display-name': , 'icon': , 'id': u'C11cbht.zap2it.com'}] **read_programmes** ``(file_object) -> list`` Get all of the programmes. Returns a list of hashes, each representing a programme, eg:: }], 'category': , 'channel': u'C23robtv.zap2it.com', 'start': u'20030702000000 ADT', 'stop': u'20030702003000 ADT', 'title': }, {'audio': }], 'channel': u'C36wuhf.zap2it.com', 'desc': , 'rating': , 'start': u'20030702000000 ADT', 'stop': u'20030702003000 ADT', 'sub-title': , 'subtitles': , 'title': }]There is also a Writer class. It should always write proper XMLTV data. Allstrings, except for dictionary keys, should be in Unicode.It contains the following methods: **__init__** ``(fp, encoding="iso-8859-1", date=None, source_info_url=None, source_info_name=None, generator_info_url=None, generator_info_name=None)`` -> ``Writer`` Returns a Writer object. Arguments: ``fp`` A File object to write XMLTV data to ``encoding`` The text encoding that will be used. *Defaults to ``iso-8859-1``* ``date`` The date this data was generated. *Optional* ``source_info_url`` A URL for information about the source of the data. *Optional* ``source_info_name`` A human readable description of ``source_info_url``. *Optional* ``generator_info_url`` A URL for information about the program that is generating the XMLTV document. *Optional* ``generator_info_name`` A human readable description of ``generator_info_url``. *Optional* **write_channel** ``(channel)`` Write a channel dictionary Here's an example channel dictionary:: {'display-name': , 'icon': , 'id': u'C11cbht.zap2it.com', 'url': u:'http://www.cbc.com'} **write_programme** ``(programme)`` Write a programme dictionary Here's an example programme dictionary:: {'audio': , 'category': , 'channel': u'C36wuhf.zap2it.com', 'country': , 'credits': , 'actor': }], 'date': , 'desc': , 'episode-num': , 'language': , 'last-chance': , 'length': , 'new': , 'orig-language': , 'premiere': , 'previously-shown': , 'rating': , 'system': u'VCHIP', 'value': u'PG'}], 'star-rating': , 'value': u'4/5'}], 'start': u'20030702000000 ADT', 'stop': u'20030702003000 ADT', 'sub-title': , 'subtitles': , 'title': , 'video': } **end** ``()`` Write end tag Call this before closing a file.Product's homepage


python-xmltv Related Software