python-xmltvalt
============
Introduction
------------
python-xmltvalt is a Python module that provides access to XMLTV data. XMLTV is
an XML format for storing TV listings.
More information on XMLTV can be found at http://wiki.xmltv.org.
This is a fork of the original 'pythong-xmltv' project
(https://pypi.org/project/python-xmltv/) and has some slight modifications
to resolve issues I found when trying to implement solutions for another
(forthcoming) open source project.
Many thanks to the original author, and the individual who cloned the
original code (https://github.com/mforkel/python-xmltv).
Requirements
------------
There are no requirements for Python 3.12 and up.
Usage
-----
Usage of the module is generally straight-forward::
import xmltv_alt
from pprint import pprint
# If you need to change the locale:
# xmltv_alt.locale = 'Latin-1'
# If you need to change the date format used in the XMLTV file:
# xmltv_alt.date_format = '%Y%m%d%H%M%S %Z'
filename = '/path/to/xmltv/file'
# Print info for XMLTV file (source, etc.)
pprint(xmltv_alt.read_data(open(filename, 'r')))
# Print channels
pprint(xmltv_alt.read_channels(open(filename, 'r')))
# Print programmes
pprint(xmltv_alt.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 <tv> attributes, eg::
{'date': u'20030702230041 -0300',
'generator-info-name': u'tv_grab_na V3.20030629',
'generator-info-url': u'http://sourceforge.net/projects/xmltv',
'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::
[{'display-name': [(u'Channel 10 ELTV', u'')],
'id': u'C10eltv.zap2it.com'},
{'display-name': [(u'Channel 11 CBHT', u'')],
'icon': [{'desc': '','src': u'http://tvlistings2.zap2it.com/tms_network_logos/cbc.gif'}],
'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::
[{'audio': [{'stereo': [u'stereo']}],
'category': [(u'Biz', u''), (u'Fin', u'')],
'channel': u'C23robtv.zap2it.com',
'start': u'20030702000000 ADT',
'stop': u'20030702003000 ADT',
'title': [(u'This Week in Business', u'')]},
{'audio': [{'stereo': [u'stereo']}],
'channel': u'C36wuhf.zap2it.com',
'desc': [(u'In an effort to grow up, George proposes marriage to former girlfriend Susan.',
u'')],
'rating': [{'system': u'VCHIP', 'value': u'PG'}],
'start': u'20030702000000 ADT',
'stop': u'20030702003000 ADT',
'sub-title': [(u'The Engagement', u'')],
'subtitles': [{'type': u'teletext'}],
'title': [(u'Seinfeld', u'')]}]
There is also a Writer class. It should always write proper XMLTV data. All
strings, 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': [(u'Channel 11 CBHT', u'en')],
'icon': [{'src': u'http://tvlistings2.zap2it.com/tms_network_logos/cbc.gif'}],
'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': [{'stereo': u'stereo'}],
'category': [(u'Comedy', u'')],
'channel': u'C36wuhf.zap2it.com',
'country': [(u'USA', u'')],
'credits': [{'producer': [u'Larry David'], 'actor': [u'Jerry Seinfeld']}],
'date': [u'1995'],
'desc': [(u'In an effort to grow up, George proposes marriage to former girlfriend Susan.',
u'')],
'episode-num': [(u'7 . 1 . 1/1', u'xmltv_ns')],
'language': [(u'English', u'')],
'last-chance': [(u'Hah!', u'')],
'length': [{'units': u'minutes', 'length': 22}],
'new': [1],
'orig-language': [(u'English', u'')],
'premiere': [(u'Not really. Just testing', u'en')],
'previously-shown': [{'channel': u'C12whdh.zap2it.com',
'start': u'19950921103000 ADT'}],
'rating': [{'icon': [{'height': u'64',
'src': u'http://some.ratings/PGicon.png',
'width': u'64'}],
'system': u'VCHIP',
'value': u'PG'}],
'star-rating': [{'icon': [{'height': u'32',
'src': u'http://some.star/icon.png',
'width': u'32'}],
'value': u'4/5'}],
'start': u'20030702000000 ADT',
'stop': u'20030702003000 ADT',
'sub-title': [(u'The Engagement', u'')],
'subtitles': [{'type': u'teletext', 'language': (u'English', u'')}],
'title': [(u'Seinfeld', u'')],
'video': [{'colour': 1, 'aspect': u'4:3', 'present': 1}]}
**end** ``()``
Write end tag
Call this before closing a file.
Reporting Bugs
--------------
Please send all bugs, comments, and questions to the github repo
https://github.com/justinhorner/python-xmltv-alt
Changelog
=========
Version 1.5.0
-------------
* changes specifically for free-iptv
* renamed project to 'xmltv_alt' to easily differentiate between existing project
Version 1.4.4
-------------
* cleanup & changed from github fork
Version 1.4.3
* Add pretty_print option to Writer.write()
Version 1.4.2
-------------
* Text encoding fixes. (Patch from Jan Sušnik)
Version 1.4.1
-------------
* Updated MANIFEST.in to include all doc files
Version 1.4
-----------
* Updated to reflect current XMLTV DTD (patch from Igor Sobolev)
* Clean up for pypi release
Raw data
{
"_id": null,
"home_page": "https://github.com/justinhorner/python-xmltv-alt",
"name": "python-xmltvalt",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Justin Horner, James Oakley",
"author_email": "mail@justinhorner.me, jfunk@funktronics.ca",
"download_url": "https://files.pythonhosted.org/packages/c6/00/e183b945c7f3f0047fa0368f67f74964faba3706726b4a0d8c818dca023e/python-xmltvalt-1.5.1.tar.gz",
"platform": null,
"description": "python-xmltvalt\n============\n\nIntroduction\n------------\npython-xmltvalt is a Python module that provides access to XMLTV data. XMLTV is\nan XML format for storing TV listings.\n\nMore information on XMLTV can be found at http://wiki.xmltv.org.\n\nThis is a fork of the original 'pythong-xmltv' project\n(https://pypi.org/project/python-xmltv/) and has some slight modifications\nto resolve issues I found when trying to implement solutions for another\n(forthcoming) open source project.\n\nMany thanks to the original author, and the individual who cloned the\noriginal code (https://github.com/mforkel/python-xmltv).\n\nRequirements\n------------\nThere are no requirements for Python 3.12 and up.\n\n\nUsage\n-----\nUsage of the module is generally straight-forward::\n\n import xmltv_alt\n from pprint import pprint\n\n # If you need to change the locale:\n # xmltv_alt.locale = 'Latin-1'\n\n # If you need to change the date format used in the XMLTV file:\n # xmltv_alt.date_format = '%Y%m%d%H%M%S %Z'\n\n filename = '/path/to/xmltv/file'\n\n # Print info for XMLTV file (source, etc.)\n pprint(xmltv_alt.read_data(open(filename, 'r')))\n\n # Print channels\n pprint(xmltv_alt.read_channels(open(filename, 'r')))\n\n # Print programmes\n pprint(xmltv_alt.read_programmes(open(filename, 'r')))\n\nThere are currently three functions for reading that should be used:\n\n **read_data** ``(file_object) -> dict``\n Get the source and other info from an XMLTV file.\n\n Returns a dictionary of <tv> attributes, eg::\n\n {'date': u'20030702230041 -0300',\n 'generator-info-name': u'tv_grab_na V3.20030629',\n 'generator-info-url': u'http://sourceforge.net/projects/xmltv',\n 'source-info-name': u'Zap2It',\n 'source-info-url': u'http://www.zap2it.com'}\n\n **read_channels** ``(file_object) -> list``\n Get all of the channels.\n\n Returns a list of hashes, each representing a channel, eg::\n\n [{'display-name': [(u'Channel 10 ELTV', u'')],\n 'id': u'C10eltv.zap2it.com'},\n {'display-name': [(u'Channel 11 CBHT', u'')],\n 'icon': [{'desc': '','src': u'http://tvlistings2.zap2it.com/tms_network_logos/cbc.gif'}],\n 'id': u'C11cbht.zap2it.com'}]\n\n **read_programmes** ``(file_object) -> list``\n Get all of the programmes.\n\n Returns a list of hashes, each representing a programme, eg::\n\n [{'audio': [{'stereo': [u'stereo']}],\n 'category': [(u'Biz', u''), (u'Fin', u'')],\n 'channel': u'C23robtv.zap2it.com',\n 'start': u'20030702000000 ADT',\n 'stop': u'20030702003000 ADT',\n 'title': [(u'This Week in Business', u'')]},\n {'audio': [{'stereo': [u'stereo']}],\n 'channel': u'C36wuhf.zap2it.com',\n 'desc': [(u'In an effort to grow up, George proposes marriage to former girlfriend Susan.',\n u'')],\n 'rating': [{'system': u'VCHIP', 'value': u'PG'}],\n 'start': u'20030702000000 ADT',\n 'stop': u'20030702003000 ADT',\n 'sub-title': [(u'The Engagement', u'')],\n 'subtitles': [{'type': u'teletext'}],\n 'title': [(u'Seinfeld', u'')]}]\n\nThere is also a Writer class. It should always write proper XMLTV data. All\nstrings, except for dictionary keys, should be in Unicode.\n\nIt contains the following methods:\n\n **__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``\n Returns a Writer object.\n\n Arguments:\n\n ``fp``\n A File object to write XMLTV data to\n\n ``encoding``\n The text encoding that will be used. *Defaults to\n ``iso-8859-1``*\n\n ``date``\n The date this data was generated. *Optional*\n\n ``source_info_url``\n A URL for information about the source of the data. *Optional*\n\n ``source_info_name``\n A human readable description of ``source_info_url``.\n *Optional*\n\n ``generator_info_url``\n A URL for information about the program that is generating the\n XMLTV document. *Optional*\n\n ``generator_info_name``\n A human readable description of ``generator_info_url``.\n *Optional*\n\n **write_channel** ``(channel)``\n Write a channel dictionary\n\n Here's an example channel dictionary::\n\n {'display-name': [(u'Channel 11 CBHT', u'en')],\n 'icon': [{'src': u'http://tvlistings2.zap2it.com/tms_network_logos/cbc.gif'}],\n 'id': u'C11cbht.zap2it.com',\n 'url': u:'http://www.cbc.com'}\n\n **write_programme** ``(programme)``\n Write a programme dictionary\n\n Here's an example programme dictionary::\n\n {'audio': [{'stereo': u'stereo'}],\n 'category': [(u'Comedy', u'')],\n 'channel': u'C36wuhf.zap2it.com',\n 'country': [(u'USA', u'')],\n 'credits': [{'producer': [u'Larry David'], 'actor': [u'Jerry Seinfeld']}],\n 'date': [u'1995'],\n 'desc': [(u'In an effort to grow up, George proposes marriage to former girlfriend Susan.',\n u'')],\n 'episode-num': [(u'7 . 1 . 1/1', u'xmltv_ns')],\n 'language': [(u'English', u'')],\n 'last-chance': [(u'Hah!', u'')],\n 'length': [{'units': u'minutes', 'length': 22}],\n 'new': [1],\n 'orig-language': [(u'English', u'')],\n 'premiere': [(u'Not really. Just testing', u'en')],\n 'previously-shown': [{'channel': u'C12whdh.zap2it.com',\n 'start': u'19950921103000 ADT'}],\n 'rating': [{'icon': [{'height': u'64',\n 'src': u'http://some.ratings/PGicon.png',\n 'width': u'64'}],\n 'system': u'VCHIP',\n 'value': u'PG'}],\n 'star-rating': [{'icon': [{'height': u'32',\n 'src': u'http://some.star/icon.png',\n 'width': u'32'}],\n 'value': u'4/5'}],\n 'start': u'20030702000000 ADT',\n 'stop': u'20030702003000 ADT',\n 'sub-title': [(u'The Engagement', u'')],\n 'subtitles': [{'type': u'teletext', 'language': (u'English', u'')}],\n 'title': [(u'Seinfeld', u'')],\n 'video': [{'colour': 1, 'aspect': u'4:3', 'present': 1}]}\n\n **end** ``()``\n Write end tag\n\n Call this before closing a file.\n\nReporting Bugs\n--------------\nPlease send all bugs, comments, and questions to the github repo\nhttps://github.com/justinhorner/python-xmltv-alt\n\n\nChangelog\n=========\n\nVersion 1.5.0\n-------------\n* changes specifically for free-iptv\n* renamed project to 'xmltv_alt' to easily differentiate between existing project\n\nVersion 1.4.4\n-------------\n* cleanup & changed from github fork\n\nVersion 1.4.3\n* Add pretty_print option to Writer.write()\n\nVersion 1.4.2\n-------------\n* Text encoding fixes. (Patch from Jan Su\u0161nik)\n\nVersion 1.4.1\n-------------\n* Updated MANIFEST.in to include all doc files\n\nVersion 1.4\n-----------\n* Updated to reflect current XMLTV DTD (patch from Igor Sobolev)\n* Clean up for pypi release\n",
"bugtrack_url": null,
"license": "LGPL-3.0+",
"summary": "A Python Module for Reading and Writing XMLTV Files",
"version": "1.5.1",
"project_urls": {
"Homepage": "https://github.com/justinhorner/python-xmltv-alt"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3108b8cca27d4771ad69291b290e76e2348eeb6c8cb3e36905177e25d45fb9ae",
"md5": "20560ed098b0717e844e3f6a95617e87",
"sha256": "6ac6a976abb0eced7838318aaaa36ab6c734cbe4e8963bbbcaccf8767189371a"
},
"downloads": -1,
"filename": "python_xmltvalt-1.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "20560ed098b0717e844e3f6a95617e87",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 13063,
"upload_time": "2024-02-07T21:20:15",
"upload_time_iso_8601": "2024-02-07T21:20:15.458763Z",
"url": "https://files.pythonhosted.org/packages/31/08/b8cca27d4771ad69291b290e76e2348eeb6c8cb3e36905177e25d45fb9ae/python_xmltvalt-1.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c600e183b945c7f3f0047fa0368f67f74964faba3706726b4a0d8c818dca023e",
"md5": "331775d1ffdc762bf9e3128e782523f6",
"sha256": "783ebc51374d00bc74d7c78011133575ccc091bdf5b28cfcbe9bdbc68fc27bc7"
},
"downloads": -1,
"filename": "python-xmltvalt-1.5.1.tar.gz",
"has_sig": false,
"md5_digest": "331775d1ffdc762bf9e3128e782523f6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 21805,
"upload_time": "2024-02-07T21:20:17",
"upload_time_iso_8601": "2024-02-07T21:20:17.283361Z",
"url": "https://files.pythonhosted.org/packages/c6/00/e183b945c7f3f0047fa0368f67f74964faba3706726b4a0d8c818dca023e/python-xmltvalt-1.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-07 21:20:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "justinhorner",
"github_project": "python-xmltv-alt",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "python-xmltvalt"
}