Exemplo n.º 1
0
def getFrenchTitle(title):
    """
    This function uses Allocine API to get the French movie title of the given title.
    It does so by searching for movies with the given title. 

    By default, Allocine search for both original title or French title, so the search
        returns the movie if the given title is original one or french one.
    Then, we look for the french title in the first result. If there is not, we fall 
        back to original title (usually the same if the french title is not there).
    """

    # open the api and create the request
    api = allocine()
    log.debug('Looking for French title of : ' + title)
    try:
        search = api.search(title)
    except urllib2.HTTPError:
        # An HTTP error means there is something going on with Allocine, 
        # or the keys used by the program to connect to the API are not working any more.
        log.error('Allocine API is not working. You should test if Allocine is still alive and check the connection keys')
        return None

    # check if there is a result
    if 'movie' not in search['feed'].keys():
        log.debug('Allocine could not find a movie corresponding to : ' + title)
        return None

    # if there is a result, extract first result
    firstResult = search['feed']['movie'][0]
    newTitle = ''
    # check if title is existing. If it is, it's the french name and we are good
    if 'title' in firstResult.keys():
        newTitle = firstResult['title'].encode('utf-8')
    # if not, original and french title are the same so return nothing
    else:
        newTitle = firstResult['originalTitle'].encode('utf-8')
        
    # Then, we check if the new title is the same as the given one. If not, return it
    if (title == newTitle):
        log.debug('Allocine API found the movie but it is the same title.')
        return None
    else:
        log.debug('Allocine API found the french title : ' + newTitle)
        return newTitle
Exemplo n.º 2
0
import pprint
from allocine import allocine

api = allocine()
api.configure('100043982026','29d185d98c984a359e6e6f26a0474269')

search = api.search("Fight club", "movie")
print "Search result Count [{0}] Code [{1}] Title [{2}]".format(search['feed']['totalResults'],
                                                                search['feed']['movie'][0]['code'],
                                                                search['feed']['movie'][0]['originalTitle'])

movie = api.movie(27405)
print "Movie Title [{0}]".format(movie['movie']['originalTitle'])

serie = api.tvseries(223)
print "Serie Title [{0}]".format(serie['tvseries']['originalTitle'])

season = api.season(12277)
print "Season Number [{0}]".format(season['season']['seasonNumber'])

episode = api.episode(247699)
print "Episode Number [{0}] Title [{1}]".format(episode['episode']['episodeNumberSeason'], episode['episode']['originalTitle'])
import sys
import os.path
import unicodedata
import Tkinter
import shutil
import tkFileDialog
import glob
import pprint
from allocine import allocine
import urllib
import urllib2
import logging
import mechanize
import re
from bs4 import BeautifulSoup
api = allocine()
api.configure('100043982026','29d185d98c984a359e6e6f26a0474269')
global lastgsearch
global waittime
global countyoutube
global countdaily
countyoutube=0
countdaily=0
waittime=0
lastgsearch=0

def logg(str,debug=None):
    ts=datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S')
    if debug==None:
        print(ts +' : '+str)
    logging.info(ts+' : '+str)