-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetflix.py
47 lines (39 loc) · 1.36 KB
/
netflix.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from pyflix2 import *
from movie import movie
import ConfigParser
import os
class Netflix(object):
"""
Netflix API
"""
def __init__(self):
section = 'netflix'
config = ConfigParser.SafeConfigParser()
config.readfp(open('config.conf'))
if not config.has_section(section):
raise ValueError('Config section {0} does not exists'.format(section))
KEY=config.get(section,'KEY')
SHARED_SECRET=config.get(section,'SHARED_SECRET')
self.service = NetflixAPIV2('Where Is Movie', KEY, SHARED_SECRET)
def get_movie_by_title(self, title, filter=None):
'''
Args:
title - Title of the movie
filter - streaming or dvd
'''
res = self.service.get_movie_by_title(title, filter=filter)
if not res:
return {}
m_details = self.service.get_title(res.get('id'), category="format_availability")
m = movie(str(res.get('title')), 'Netflix')
# Check for formats
if m_details.get('delivery_formats'):
f = m_details.get('delivery_formats')
if f.get('DVD'):
m.dvd = True
m.price_dvd = 'subscription'
if f.get('instant'):
m.stream = True
m.price_stream = 'subscription'
# return the movie dict
return m