예제 #1
0
 def movielist_loader(conn, url):
     """Function to be run in a separate process. It will send
     movie list through pipe. Use poll() to verify that data is ready.
     """
     try:
         log.info("getting movie list from %s" % url)
         movies = amt.getMoviesFromJSON(url)
         conn.send((None, movies))
         conn.close()
     except URLError as e:
         log.error("network problem error while loading movie list: %s" % e)
         log.error(traceback.format_exc())
         conn.send((e, None))
     except socket.error as e:
         log.error("network problem error while loading movie list: %s" % e)
         log.error(traceback.format_exc())
         conn.send((e, None))
     except Exception as e:
         log.error("uncaught exception ocurred while loading movie list. Please report this!")
         log.error(traceback.format_exc())
         conn.send((e, None))
예제 #2
0
# -*- coding: utf-8 -*-

import sys

import urllib2
import pytrailer
import re

resMatcher = re.compile(r"_h([0-9]+p?)\.mov")

jsonURL = "http://trailers.apple.com/trailers/home/feeds/genres.json"

movies = pytrailer.getMoviesFromJSON(jsonURL)

i = 0
for movie in movies:
    desc = ", ".join([x["type"] for x in movie.trailers])
    print "%d\t%s [%s]" % (i, movie.title, desc)
    i += 1

sys.stdout.write("Choose movie: ")
selection = sys.stdin.readline()

index = 0
try:
    index = int(selection)
except:
    print "You are a moron!"
    sys.exit(1)

toload = movies[index]
예제 #3
0
            savePath = arg

            if not os.path.isdir(savePath):
                print 'Folder path does not exist: ' + savePath
                sys.exit(1)

        #Remove last argument
        argsList = argsList[1:]
        
    if loggingLevel == "debug":
        logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
        logging.debug('Verbose logging enabled')
    elif loggingLevel == "info":
        logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
        
    aptMovies = pytrailer.getMoviesFromJSON('http://trailers.apple.com/trailers/home/feeds/just_added.json')
    logging.info('Retrieved details for ' + str(len(aptMovies)) + ' movies')
    
    for movie in aptMovies:
        urlFetch = downloadLinkForMovie(movie,height)

        aptSaveName = fileNameForMovie(movie)
        
        '''Get file extension from end of url, otherwise assume mov'''
        if '.' in urlFetch:
            aptSaveName += '.' + urlFetch.split('.')[-1].lower()
        else:
            aptSaveName += '.mov'
        
        aptSavePath = os.path.join(savePath,aptSaveName)