Beispiel #1
0
    def run(self, title):
        info = {}

        show = Show.objects.get(title_en=title)

        imdb_show, ok = do_long_imdb_operation(getmovie_by_id, args=show.imdb_id, timeout=4)

        imdb_show, ok = do_long_imdb_operation(update_episodes, args=imdb_show, timeout=10)

        for s in imdb_show['episodes']:
            try:
              season , created = Season.objects.get_or_create(season_num=s, part_of=show)
            except: continue
            for e in imdb_show['episodes'][s]:
                try:  episode_num = imdb_show['episodes'][s][e]['episode']
                except: episode_num = 0

                try:  title = imdb_show['episodes'][s][e]['title']
                except: title = 'No found'

                try: plot = imdb_show['episodes'][s][e]['plot']
                except: plot = 'No found'

                #TODO:
                #air_date = imdb_show['episodes'][s][e]['original air date']
                episode , created = Episode.objects.get_or_create(
                                                                    title_en = title,
                                                                    episode_num=episode_num,
                                                                    part_of=season)
                episode.summary_en = plot
               
                episode.save()
        info['success'] = True
        return info
Beispiel #2
0
    def run(self, show_id):
        info = {}
        show, ok = do_long_imdb_operation(getmovie_by_id, args=show_id, timeout=4)
        if ok:
            try: info['title'] = show['title']
            except KeyError: pass

            try: info['plot'] = show['plot'][0]
            except KeyError: pass

            try: info['rating'] = show['rating']
            except KeyError:  pass

            try: info['cover_url'] = show['cover url']
            except KeyError: pass

            try :  info['years'] = show['series years']
            except KeyError: pass

            try :
                # load seven first actors
                info['cast']  = str(json.dumps([ {'id':x.personID, 'name':x['long imdb name']} for x in show['cast'] ][0:7]))
            except KeyError: pass

            try :  info['genre'] = str(json.dumps([str(m) for m in show['genres']]))
            except KeyError: pass
        else:
            info['error'] = True
        return info
Beispiel #3
0
 def run(self, movie_id,  filter=None):
     info = {}
     movie, ok = do_long_imdb_operation(getmovie_by_id, args=movie_id, timeout=4)
     if ok:    
         try: info['title'] = movie['title']
         except KeyError: pass
         
         try: info['plot'] = movie['plot'][0]
         except KeyError: pass
         
         try: info['rating'] = movie['rating']
         except KeyError:  pass
         
         try: info['cover_url'] = movie['cover url'] 
         except KeyError: pass
         
         try: info['imdb_url'] = "http://www.imdb.com/title/tt"+movie_id+"/"
         except KeyError: pass
         
         try :  info['year'] = movie['year']
         except KeyError: pass
         
         try : 
             # load seven first actors
             info['cast']  = str(json.dumps([ {'id':x.personID, 'name':x['long imdb name']} for x in movie['cast'] ][0:7]))
         except KeyError: pass
         
         try :  info['genre'] = str(json.dumps([str(m) for m in movie['genres']]))
         except KeyError: pass
     else:
         info['error'] = True
         
     return info
Beispiel #4
0
 def run(self, title,  filter=None):
     info = {}
     movie_list, ok = do_long_imdb_operation(search_movie_by_title, args=title, timeout=5)
     if ok:
         if filter is not None:
             info['list'] = [{'id':x.movieID, 'title':x['long imdb canonical title']} for x in movie_list if x['kind']==filter]
         else:
             info['list'] = [{'id':x.movieID, 'title':x['long imdb canonical title']} for x in movie_list]
     else:
         info['error'] = True
     return info
Beispiel #5
0
    def run(self, name):
        info = {}
        info['list'] = []
        actors, ok = do_long_imdb_operation(search_person_by_name, args=name, timeout=5)
        if ok:
            for actor in actors:
                id = actor.personID
                found_name = actor['long imdb canonical name']

                info['list'].append({'id':id, 'name':found_name })
        else:
            info['error'] = True

        return info
Beispiel #6
0
    def run(self, person_id, save_to_db=False,  **kwargs):
        from utils.helper import translate_with_wiki
        from persons.models import Actor
        from persons.views import save_mugshot
        info = {}
        
        person, ok = do_long_imdb_operation(getperson_by_id, args=person_id, timeout=4)
        if ok:
            
            print person.keys()
            try: info['name'] = person['name'].replace(' - IMDb','')
            except KeyError: pass

            try: info['bio'] = person['mini biography'][0]
            except KeyError: pass

            try: info['headshot'] = person['headshot']
            except KeyError: pass

            try: info['imdb_url'] = "http://www.imdb.com/name/nm"+person_id+"/"
            except KeyError: pass

            try :  info['birth_date'] = person.data['birth date']
            except KeyError: pass
           
            if save_to_db:
                
                act, created = Actor.objects.get_or_create(name_en=info['name'] )

                if 'bio' in info.keys():  
                    act.bio_en = unicode(info['bio'])

                he_name =  translate_with_wiki('he',info['name'])
                if he_name is not None:
                    act.name_he = he_name.decode('unicode_escape')

                ru_name =  translate_with_wiki('ru',info['name'])
                if ru_name is not None:
                    act.name_ru = ru_name.decode('unicode_escape')

                act.imdb_url = unicode(info['imdb_url'])

                if 'headshot' in info.keys(): 
                    save_mugshot(act, info['headshot'] )

                act.save()
        else:
            info['error'] = True

        return info