Ejemplo n.º 1
0
    def setUp(self):
        '''Set up the data to use in test'''

        # First list for testing
        self.list1 = MovieInfo(
            [2018, 0, 6.3, 141, 51, 62, 58.03, "action", "sci-fi", "january"])

        # Second list for testing
        self.list2 = MovieInfo([
            2018, 6, 8.8, 149, 68, 321, 257.7, "action", "adventure", "april"
        ])
Ejemplo n.º 2
0
def mapview():
	movie_name = request.form.get('Movie')
	if request.method == 'POST' and movie_name != "":
		M = MovieInfo(movie_name)
		movie_dict = M.get_movie_info()
		image_file = movie_dict['Poster']
		sndmap = Map(
			identifier="sndmap",
			lat=37.4419,
			lng=-122.1419,
			style="height:50%;width:50%;top:6000;left:1000;position:absolute;z-index:200",
			markers={'http://maps.google.com/mapfiles/ms/icons/green-dot.png': [(37.4419, -122.1419)],
			         'http://maps.google.com/mapfiles/ms/icons/blue-dot.png': [(37.4300, -122.1400)]}
		)
		return render_template('home.html', movie=movie_name, sndmap=sndmap, movie_info=movie_dict,
		                       image=image_file)
	else:
		return render_template('home.html', movie=movie_name)
Ejemplo n.º 3
0
 def timerStateChanged(self, timer):
     try:
         from timer import TimerEntry
         print "timer.event", timer.name
         print "timer.state", timer.state
         if timer.state == TimerEntry.StateEnded:
             print "TimerEntry", timer.name
             if not timer.Filename:
                 print "cancel, no timer filename"
                 return
             filename = timer.Filename.endswith(
                 ".ts") and timer.Filename or timer.Filename + ".ts"
             print filename
             mi = MovieInfo(timer.name, None, file_name=filename)
             serviceref = mi.createService()
             mi.serviceref = serviceref
             mi.info = self.serviceHandler.info(serviceref)
             mi.begin = mi.info.getInfo(serviceref,
                                        iServiceInformation.sTimeCreate)
             movie_path = os.path.dirname(mi.serviceref.getPath()) + os.sep
             print movie_path
             self.movielibrary.addMovie(movie_path, mi)
             self.updateReloadTime()
             print "add:", mi
     except:
         printStackTrace()
Ejemplo n.º 4
0
class TestMovieInfo(unittest.TestCase):
    '''Unit Test to test the MovieInfo Class'''
    def setUp(self):
        '''Set up the data to use in test'''

        # First list for testing
        self.list1 = MovieInfo(
            [2018, 0, 6.3, 141, 51, 62, 58.03, "action", "sci-fi", "january"])

        # Second list for testing
        self.list2 = MovieInfo([
            2018, 6, 8.8, 149, 68, 321, 257.7, "action", "adventure", "april"
        ])

    def test_EntryNumbers(self):
        '''Test that the function will return a list of numeric data'''

        # Expected result 1
        self.list1_result = [0, 6.3, 141, 51, 62, 58.03]

        # Expected result 2
        self.list2_result = [6, 8.8, 149, 68, 321, 257.7]

        # Pass through the test matrices and compare to expected result
        self.assertListEqual(self.list1.getEntryNumbers(), self.list1_result)
        self.assertListEqual(self.list2.getEntryNumbers(), self.list2_result)

    def test_EntryWords(self):
        '''Test that the function will return a list of string data'''

        # Expected result 1
        self.list1_result = ["action", "sci-fi", "january"]

        # Expected result 2
        self.list2_result = ["action", "adventure", "april"]

        # Pass through the test matrices and compare to expected result
        self.assertListEqual(self.list1.getEntryWords(), self.list1_result)
        self.assertListEqual(self.list2.getEntryWords(), self.list2_result)
Ejemplo n.º 5
0
 def insertMarker(self, l1, root):
     if len(root) > 40:
         parts = root.split("/")
         if len(parts) > 2:
             name = "/.../" + parts[-3] + "/" + parts[-2]
         else:
             name = parts[-2]
     else:
         name = root
     serviceref = eServiceReferenceMarker(root)
     serviceref.setName("[ " + name + " ]")
     info = ServiceCenter.getInstance().info(serviceref)
     mi = MovieInfo(name, serviceref, info)
     l1.insert(0, (mi, ))
Ejemplo n.º 6
0
    def scanForMovies(self, root, addtolib=True):
        # print "[AdvancedMovieSelection] scan folder:", root

        scan_service = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + root)
        root_list = self.serviceHandler.list(scan_service)
        if root_list is None:
            print "listing of movies failed"
            return
        tags = set()
        l = []
        dirs = []
        movie_seen = 0
        while 1:
            serviceref = root_list.getNext()
            if not serviceref.valid():
                break
            dvd = None
            # print serviceref.getPath()
            # dvd structure
            if serviceref.flags & eServiceReference.mustDescent:
                dvd = detectDVDStructure(serviceref.getPath())
                if dvd is not None:
                    if serviceref.getPath()[:-1].endswith(TRASH_NAME):
                        continue
                    serviceref = eServiceReferenceDvd(serviceref, True)
                bludisc = detectBludiscStructure(serviceref.getPath())
                if bludisc is not None:
                    if serviceref.getPath()[:-1].endswith(TRASH_NAME):
                        continue
                    serviceref = eServiceReferenceBludisc(serviceref, True)

                if not dvd and not bludisc:
                    continue

                if False:
                    # add folder dir
                    tempDir = serviceref.getPath()
                    parts = tempDir.split(os.sep)
                    dirName = parts[-2]
                    if self.movieConfig.isHidden(dirName):
                        continue
                    serviceref.setName(dirName)
                    dirs.append((serviceref, None, -1, -1))
                    continue

            # check hidden files
            temp = serviceref.getPath()
            parts = temp.split(os.sep)
            if self.movieConfig.isHidden(parts[-1]):
                continue

            ext = temp.split(".")[-1].lower()
            if ext in AUDIO_EXCLUDE:
                continue

            # check currently moving files
            if serviceUtil.isServiceMoving(serviceref):
                continue

            # check iso and img files
            extension = serviceref.getPath().split(".")[-1].lower()
            if extension == "iso" or extension == "img":
                serviceref = eServiceReferenceDvd(serviceref)

            info = self.serviceHandler.info(serviceref)

            # get begin time
            if dvd is not None:
                begin = long(os.stat(dvd).st_mtime)
            else:
                begin = info.getInfo(serviceref,
                                     iServiceInformation.sTimeCreate)

            # convert space-seperated list of tags into a set
            this_tags = info.getInfoString(
                serviceref, iServiceInformation.sTags).split(' ')
            if this_tags is None or this_tags == ['']:
                this_tags = []
            this_tags = set(this_tags)
            tags |= this_tags

            # add to list
            service_name = info.getName(serviceref)
            mi = MovieInfo(service_name, serviceref, info, begin)
            l.append(mi)
            if hasLastPosition(serviceref):
                movie_seen += 1

        dir_size = 0
        # add location to movielibrary
        if addtolib:
            dir_size = getDirSize(root)
            self.movielibrary.addMovieList(root, l, dir_size, movie_seen)
            self.movielibrary.addTags(tags)
        return l, dir_size, movie_seen
Ejemplo n.º 7
0
def save_movie_info_to_mongo(title,
                             rt_id=None,
                             save_similar_movies=False,
                             overwrite=False):
    AWS_ACCESS_KEY = settings.Config.AWS_ACCESS_KEY
    AWS_SECRET_KEY = settings.Config.AWS_SECRET_KEY
    AWS_AFFILIATE_KEY = settings.Config.AWS_AFFILIATE_KEY
    ROTTEN_TOMATOES_API_KEY = settings.Config.ROTTEN_TOMATOES_API_KEY
    TMDB_API_KEY = settings.Config.TMDB_API_KEY

    if not overwrite and Movie.objects(_title=title).first() is not None:
        print "{title}found in db".format(title=title)
        return

    print "searching {title}".format(title=title)
    movie = MovieInfo(title,
                      ROTTEN_TOMATOES_API_KEY,
                      TMDB_API_KEY,
                      AWS_ACCESS_KEY,
                      AWS_SECRET_KEY,
                      AWS_AFFILIATE_KEY,
                      rt_id=rt_id)
    # save the movie's information to the database:
    # raw movie data
    cast = movie.cast
    critics_score = movie.critics_score
    director = movie.director
    genres = movie.genres
    imdb_id = movie.imdb_id
    poster = movie.poster
    release_date = movie.release_date
    reviews = movie.critic_reviews
    runtime = movie.runtime
    similar_movies = movie.similar_movies
    synopsis = movie.synopsis
    title = movie.title
    trailers = movie.trailers
    amazon_purchase_links = movie.get_amazon_purchase_links(cast[0], runtime)

    # formatting some raw data into more complex sets of data
    actors = convert_cast_json_to_obj(cast)
    amazon_purchase_links = convert_amazon_purchase_link_json_to_obj(
        amazon_purchase_links)
    formatted_director = format_string(movie.director)
    formatted_title = format_string(title)
    reviews = convert_review_json_to_obj(reviews)
    metadata = convert_to_metadata(imdb_id, runtime)
    thumbnail = create_thumbnail(formatted_title, poster, verbose=True)
    similar_movies_imdb_ids = convert_similar_movies_to_imdb_ids(
        similar_movies)

    kargs = {
        "_director": director,
        "_formatted_director": formatted_director,
        "_title": title,
        "_formatted_title": formatted_title,
        "_synopsis": synopsis,
        "_critics_score": critics_score,
        "_release_date": release_date,
        "_poster": poster,
        "_thumbnail": thumbnail,
        "_cast": actors,
        "_genres": genres,
        "_metadata": metadata,
        "_reviews": reviews,
        "_similar_movies": similar_movies_imdb_ids,
        "_trailers": trailers,
        "_purchase_links": amazon_purchase_links
    }

    if not overwrite:
        print "saving {title}".format(title=title)
        new_movie = Movie(**kargs)
        new_movie.save()
        index_movie(new_movie, verbose=True)
        update_actors(actors, new_movie, verbose=True)
    else:
        print "updating {title}".format(title=title)
        Movie.objects(_formatted_title=formatted_title).first().save(**kargs)

    # save this movie's similar movies to mongo
    if save_similar_movies:
        for similar_movie in similar_movies:
            title = similar_movie['title']
            rt_id = similar_movie['id']
            save_movie_info_to_mongo.delay(title,
                                           rt_id=rt_id,
                                           save_similar_movies=True)
            print "queuing up {title}".format(title=title)
Ejemplo n.º 8
0
    # Contains the matrix with the average of each column
    numbers_average = average_range.getMovieAverage()

    # Contains the matrix with the range (min - max) of each column
    matrix_range = average_range.getRangeMinMax()

    # Contains the dictionary
    word_count = genreMonthCount(matrix_string)

    # Get movie title from user
    title = input("Enter the name of the movie: ")

    # Get the validated input data
    movie_input = validInput()

    # Pass the data collected from user to be split into numeric and string data
    movie = MovieInfo(movie_input)

    # Contains the numeric data from user
    input_numbers = movie.getEntryNumbers()

    # Conains the string data from user
    input_words = movie.getEntryWords()

    # Pass the title, data from user (numeric and string), average and range
    #   and word frequency dictionary to add up points
    movie_points = MoviePoints(title, input_numbers, input_words,
                               numbers_average, matrix_range, word_count)

    # Prints the result from the MoviePoints class
    print(movie_points.getTotalPoints())
Ejemplo n.º 9
0
def save_movie_info_to_mongo(title, rt_id=None, save_similar_movies=False,
        overwrite=False):
    AWS_ACCESS_KEY = settings.Config.AWS_ACCESS_KEY
    AWS_SECRET_KEY = settings.Config.AWS_SECRET_KEY
    AWS_AFFILIATE_KEY = settings.Config.AWS_AFFILIATE_KEY
    ROTTEN_TOMATOES_API_KEY = settings.Config.ROTTEN_TOMATOES_API_KEY
    TMDB_API_KEY = settings.Config.TMDB_API_KEY

    if not overwrite and Movie.objects(_title=title).first() is not None:
        print "{title}found in db".format(title=title)
        return

    print "searching {title}".format(title=title)
    movie = MovieInfo(title, ROTTEN_TOMATOES_API_KEY, TMDB_API_KEY,
                AWS_ACCESS_KEY, AWS_SECRET_KEY, AWS_AFFILIATE_KEY,
                rt_id=rt_id)
    # save the movie's information to the database:
    # raw movie data
    cast = movie.cast
    critics_score = movie.critics_score
    director = movie.director 
    genres = movie.genres
    imdb_id = movie.imdb_id
    poster = movie.poster
    release_date = movie.release_date
    reviews = movie.critic_reviews
    runtime = movie.runtime
    similar_movies = movie.similar_movies
    synopsis = movie.synopsis
    title = movie.title
    trailers = movie.trailers
    amazon_purchase_links = movie.get_amazon_purchase_links(cast[0], runtime)
    
    # formatting some raw data into more complex sets of data
    actors = convert_cast_json_to_obj(cast)
    amazon_purchase_links = convert_amazon_purchase_link_json_to_obj(
        amazon_purchase_links)
    formatted_director = format_string(movie.director)
    formatted_title = format_string(title)
    reviews = convert_review_json_to_obj(reviews)
    metadata = convert_to_metadata(imdb_id, runtime)
    thumbnail = create_thumbnail(formatted_title, poster, verbose=True)
    similar_movies_imdb_ids = convert_similar_movies_to_imdb_ids(
        similar_movies)
    
    kargs ={"_director": director,
            "_formatted_director": formatted_director,
            "_title": title,
            "_formatted_title": formatted_title, 
            "_synopsis": synopsis,
            "_critics_score": critics_score,
            "_release_date": release_date,
            "_poster": poster,
            "_thumbnail": thumbnail,
            "_cast": actors, 
            "_genres": genres,
            "_metadata": metadata, 
            "_reviews": reviews,
            "_similar_movies": similar_movies_imdb_ids,
            "_trailers": trailers,
            "_purchase_links": amazon_purchase_links}

    if not overwrite:
        print "saving {title}".format(title=title)
        new_movie = Movie(**kargs)
        new_movie.save()
        index_movie(new_movie, verbose=True)
        update_actors(actors, new_movie, verbose=True)
    else:
        print "updating {title}".format(title=title)
        Movie.objects(_formatted_title=formatted_title).first().save(**kargs)

    # save this movie's similar movies to mongo
    if save_similar_movies:
        for similar_movie in similar_movies:
            title = similar_movie['title']
            rt_id = similar_movie['id']
            save_movie_info_to_mongo.delay(title, rt_id=rt_id, 
                save_similar_movies=True)
            print "queuing up {title}".format(title=title)