Skip to main content

n.tv api

Project description

https://badge.fury.io/py/ntv.png https://travis-ci.org/onjin/ntv.png?branch=master https://pypip.in/d/ntv/badge.png

Python wrapper over n.pl movies schedule.

  • Free software: BSD license

Features

  • python wrapper over tv program from n.pl site

  • ntv-cli command utility to list and search tv program

Installation

  • pip install ntv

CLI usage

List channels from today schedule:

  • ntv-cli channels

Find channel by id or by name

  • ntv-cli channels film

  • ntv-cli channels -c 833

Display all movies from today schedule

  • ntv-cli movies

Find movies by channel name or/and movie name

  • ntv-cli movies axn

  • ntv-cli movies comedy -t madagaskar

Change schedule date by adding -d option:

  • ntv-cli channels -d 2013-12-24

  • ntv-cli movies -d 2013-12-24

API

ntv.shortcuts.search

Shorcut function to search n.pl schedule and get result as dictionary

Example usage:

from ntv.shortcuts import search

print search()
print search(datetime.today())

print search(datetime.today(), channel_id=8)
print search(datetime.today(), channel_name='comedy')
print search(datetime.today(), movie_title='braindead')
print search(datetime.today(), channel_name='comedy', movie_title='braindead')

Example result:

{
    1313: {
        'index': 1313,
        'name': 'First channel',
        'movies': [
            {
                'title': '1st movie',
                'start_time': datetime.strptime(
                    '2013-10-12 00:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'end_time': datetime.strptime(
                    '2013-10-12 01:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'inf': False
            },
            {
                'title': '2nd movie',
                'start_time': datetime.strptime(
                    '2013-10-12 01:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'end_time': datetime.strptime(
                    '2013-10-12 02:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'inf': False
            },
            {
                'title': '3rd movie',
                'start_time': datetime.strptime(
                    '2013-10-12 02:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'end_time': datetime.strptime(
                    '2013-10-12 03:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'inf': False
            },
        ]
    },
    1414: {
        'index': 1414,
        'name': 'Second channel',
        'movies': [
            {
                'title': '1st movie',
                'start_time': datetime.strptime(
                    '2013-10-12 00:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'end_time': datetime.strptime(
                    '2013-10-12 01:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'inf': False
            },
            {
                'title': '2nd movie',
                'start_time': datetime.strptime(
                    '2013-10-12 01:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'end_time': datetime.strptime(
                    '2013-10-12 02:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'inf': False
            },
            {
                'title': '3rd movie',
                'start_time': datetime.strptime(
                    '2013-10-12 02:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'end_time': datetime.strptime(
                    '2013-10-12 03:00:00', '%Y-%m-%d %H:%M:%S'
                ),
                'inf': False
            },
        ]
    },
}

Low-level API

ntv.web.fetcher

Gets raw data from website as

from ntv.web import fetcher

print fetcher()
print fetcher(datetime.today())

ntv.web.result_to_dict

Changes raw result from fetcher into final dictionary

from ntv.web import fetcher, result_to_dict

print result_to_dict(fetcher())

ntv.web.filtered

Filters result dict using params: channel_id, channel_name, movie_title

from ntv.web import fetcher, result_to_dict, filtered

print filtered(result_to_dict(fetcher()), channel_name='canal')

History

0.3.3 (2013-11-08)

  • Fixed -d option

0.3.2 (2013-11-03)

  • Added ‘on_air’ -a option

0.3.1 (2013-10-25)

  • Fixed filtering using channel and movie together

0.3.0 (2013-10-11)

  • Changed dict.itermitems() to items() for compatibility with python 3.x

0.2.0 (2013-10-11)

  • Fixed utf-8 input titles and names

0.1.0 (2013-10-11)

  • First release on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ntv-0.4.4.tar.gz (16.2 kB view hashes)

Uploaded Source

Built Distribution

ntv-0.4.4-py2.py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page