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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2 Python 3

File details

Details for the file ntv-0.4.4.tar.gz.

File metadata

  • Download URL: ntv-0.4.4.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ntv-0.4.4.tar.gz
Algorithm Hash digest
SHA256 53e18a080061363b2bba66afdfd0ac81b8ae3b6f8a1ec6bff54d803334328786
MD5 40c5ded49fc6b343effdb5641ea99657
BLAKE2b-256 649bd4e4f5a3160bbb74728d10c590bb45a8796978b76df32978d226e12ee03d

See more details on using hashes here.

File details

Details for the file ntv-0.4.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for ntv-0.4.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a5df635b289fc57d1cba11d099620e908a67108660cfc98ea0330cdbe6e29b0d
MD5 b28955197560a40777342f3c4784632c
BLAKE2b-256 53aa97776c49434b7d7262226b6d6603151090c42fdf61ced2fa9f34cf9ea6e6

See more details on using hashes here.

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