Skip to content

Instantly share code, notes, and snippets.

@raymonstah
Created October 9, 2014 05:11
Show Gist options
  • Save raymonstah/2dcc4a91ae1e29354016 to your computer and use it in GitHub Desktop.
Save raymonstah/2dcc4a91ae1e29354016 to your computer and use it in GitHub Desktop.
# Raymond Ho
# Oct 7, 2014
"""
Checks if the movie / TV show you've been waiting for is finally up on Netflix,
or if they have new seasons / episodes, whatever. Only works if Netflix updated
in the past two weeks.
"""
from urllib import request, parse # Used to generate URLs and open links
from bs4 import BeautifulSoup # Used to parse HTML
BASEURL = 'http://instantwatcher.com/'
INSTANTWATCHER = BASEURL + '/titles/popular_new/'
# This is your list of TV shows and movies, checks if updated on netflix.
my_movies = ['Walking Dead',
'Vampire Diaries',
'Pretty Little Liars',
'Blacklist',
'Originals',
'Bones'
]
def check_page(url):
""" Returns a list of movies/link given a link """
link_soup = BeautifulSoup(request.urlopen(url).read())
results = []
for link in link_soup.findAll('a', {'class': 'title-list-item-link title-detail-link'}):
pair = link.text, BASEURL+link.get('href')
results.append(pair)
return results
def check_all_pages(link):
""" Gets the total movies/link from all pages """
total_pages = 6
total_result = []
for page in range(1, total_pages+1):
print ('Checking page:', page)
link_page = link + str(page)
# Combine list
total_result += check_page(link_page)
return total_result
def main():
movies = check_all_pages(INSTANTWATCHER)
results = []
# Check if any matches found
for movie in movies:
for my_movie in my_movies:
if my_movie.lower() in movie[0].lower():
results.append(movie)
# Print the results
if not results:
print('\nSorry, nothing found.')
else:
print('\nI found the following:\n')
for movie in results:
print(movie[0], '(' + movie[1] + ')')
if __name__ == '__main__':
main()
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment