Exemplo n.º 1
0
def main():
    movie = Movie.Movie()
    movie.title = 'The Square'
    movie_2 = Movie.Movie()
    movie_2.title = '9'
    movie_3 = Movie.Movie()
    movie_3.title = 'my Neighbor Totoro'
    movies = [movie, movie_2, movie_3]

    print filter(makeHaveSeenFilter(getMovieBlackListSet()), movies)
def getRating():
    import Movie as M
    M.getFinalRating()
    data = ""
    with open(
            "/home/tharindra/PycharmProjects/WorkBench/DataMiningAssignment/hello.txt"
    ) as file:
        data = file.read()
    print(data)
    return data
Exemplo n.º 3
0
def page(content):
    for s in content:
        try:
            h = s('div')[0]('a')[0]['href']
            film_title = s('div')[0].getText()
            #Out[126]: u'/filmler/film-132874/'
            film_id = int(h.split('/')[2].split('-')[1])
            film_url = base_url + h + "kullanici-elestirileri/en-yeniler/?page=%d"
            m = Movie.Movie(film_id, film_title, film_url)
            film_html = get_html(film_url % 1)
            movie = get_elestiri(film_html, m)
            pager = film_html.find("div", "pager")
            if pager:
                li = pager('li')
                li.reverse()
                if li and li[0].span:
                    for i in range(2, int(li[0].span.text) + 1):
                        movie = get_elestiri(get_html(film_url % i), movie)
                else:
                    if li and li[0].a['href']:
                        movie = get_elestiri(get_html(li[0].a['href']), m)
                    else:
                        print 'error on %s' % film_url
            if len(m.reviews) > 0:
                m.persist()
                print counter
        except IndexError:
            print "IndexError"
            print s
Exemplo n.º 4
0
def get_info():
    page = requests.get(LINK)
    soup = BeautifulSoup(page.content, 'html.parser')
    tables = soup.select('.wikitable.sortable i a')
    for item in tables:
        current_movie = Movie.Movie(item['title'], 'https://en.wikipedia.org' + item['href'])
        all_movies[current_movie.box.get('name')] = current_movie.box
Exemplo n.º 5
0
def get_movie_short_comment(url):
    path = 'short_comment\\'
    id = Movie.get_movie_id(url)
    file = path + str(id) + '.txt'
    file_operation.make_empty_file(file)

    comment_str = ""
    page = 0
    num = 0
    for i in tqdm(range(1, 10)):
        while (page != 200):
            url2 = url + 'comments?start=' \
                   + str(page) + '&limit=20&sort=new_score&status=P'
            header = request_body.get_header()
            proxies = request_body.get_proxy()
            req = requests.get(url=url2, proxies=proxies, headers=header)
            html = req.text
            soup = bs4.BeautifulSoup(html, 'lxml')

            short_comment = soup.find_all('span', class_="short")
            for list in short_comment:
                comment_str = comment_str + list.text + '\n'
                num = num + 1

            page = page + 20
            #print("短评个数:" + str(num) + "页码" + str(page) + '\n')
            with open(file, 'a', encoding='utf8') as fj:
                fj.write(comment_str)
    print('--------------------------------------')
Exemplo n.º 6
0
    def ask_movies(self):
        movies = input("How many movies would you like to add?\n")
        while not movies.isdigit():
            print("Wrong input. Please enter a whole number.\n")
            movies = input("How many movies would you like to add?\n")
        movies = int(movies)
        movie_id = 0
        offset = self.cinema.largest_searchkey("movie") + 1

        while movie_id < movies:
            movie_title = input(
                "What is the title of the movie you would like to add.\n")
            movie_rating = input("What rating does the movie have?\n")
            loop = True
            while loop:
                try:
                    float(movie_rating)
                    loop = False
                except Exception:
                    print(
                        "Wrong input. The movie rating has to be a number.\n")
                    movie_rating = input("What rating does the movie have?\n")

            self.cinema.add(
                "movie", Movie(movie_id + offset, movie_title, movie_rating))
            print("Movie has been added with id: ", movie_id + offset)
            movie_id += 1
Exemplo n.º 7
0
def parseMovie(input_date, movie_soup):
    movie = Movie.Movie()
    movie.showdate = input_date
    movie.theater = 'Metrograph'

    # title and show link
    title_info = movie_soup.find('h4')
    movie.title = title_info.a.text
    movie.show_url = title_info.a['href']

    # showtime
    for showtime_a in movie_soup.find('div', {
            'class': 'showtimes'
    }).find_all('a'):
        movie.addShowTime(movie.showdate, showtime_a.text)

    # print movie.show_url

    # director, year
    details_soup = movie_soup.find('div', {'class': 'details'})
    if details_soup is None:
        print 'Cannot find movie details for: {0}'.format(movie.title)
    match = re.search('director:(.*)(\d{4})',
                      details_soup.text,
                      flags=re.IGNORECASE)

    if match is not None:
        movie.addDirectors(match.group(1))
        movie.year = match.group(2)

    return movie
Exemplo n.º 8
0
def parseMovie(input_date, movie_soup):
    movie = Movie.Movie()
    movie.showdate = input_date

    # title and show link
    title_info = movie_soup.find('div', {'class': 'details'}).find('h3')
    movie.show_url = title_info.a['href']
    movie.setTitle(title_info.a.text.encode('utf-8'))
    movie.theater = 'IFC'

    # showtime
    for showtime_li in movie_soup.find('ul', {
            'class': 'times'
    }).findChildren(recursive=False):
        movie.addShowTime(movie.showdate, showtime_li.a.text)

    # director, year (hard to find this one)
    details_soup = Common.getPageSoup(movie.show_url)
    for detail_li in details_soup.find('ul', {
            'class': 'film-details'
    }).findChildren(recursive=False):
        label = detail_li.find('strong').text
        if label.lower() == 'year':
            movie.year = re.sub('year',
                                '',
                                detail_li.text,
                                flags=re.IGNORECASE).strip()
        if label.lower() == 'director':
            movie.addDirectors(
                re.sub('director', '', detail_li.text,
                       flags=re.IGNORECASE).strip())

    return movie
Exemplo n.º 9
0
def parseMovie(input_date, movie_info_soup):
    movie = Movie.Movie()
    movie.showdate = input_date
    title_info = movie_info_soup.find('h3').find('a')
    movie.title = title_info.text
    movie.show_url = title_info['href']

    for showtime_li in movie_info_soup.find('ul', {
            'class': 'co-showtimes-list'
    }).findChildren(recursive=False):
        movie.addShowTime(input_date, showtime_li.find('a').text)

    movie_page_soup = Common.getPageSoup(movie.show_url)
    movie_metadata_lis = movie_page_soup.find('div', {
        'class': 'film-meta'
    }).find('ul').findChildren(recursive=False)
    if len(movie_metadata_lis) >= 2:
        movie.addDirectors(movie_metadata_lis[0].text)
        movie.year = movie_metadata_lis[1].text

    # Venue info
    movie.theater = movie_page_soup.find('div', {
        'class': 'venue'
    }).find('a').text
    return movie
Exemplo n.º 10
0
def loadFile(message, movies):
    filename = input(message + "\n")
    file = open(filename, "r")
    for line in file.readlines()[1:]:
        if line.startswith("\""):
            title = line.split("\"")[1]
            data = line.split("\"")[2].split(",")
            movies.append(
                Movie(title, data[1], data[2], data[3],
                      [data[4], data[5], data[6]], data[7], data[8],
                      data[9].rstrip("\n")))
        else:
            data = line.split(",")
            movies.append(
                Movie(data[0], data[1], data[2], data[3],
                      [data[4], data[5], data[6]], data[7], data[8],
                      data[9].rstrip("\n")))
Exemplo n.º 11
0
def make_movie_object_list(num_of_movies, movie_id_dict, movie_names_dict):
    """This creates a list of movie objects.
       Each movie includes a movie_title, movie_rating, and average_rating.

       Functional Argument: (num_of_movies, movie_id_dict, movie_names_dict)

           num_of_movies is set to 1682
           movie_id_dict is dict of moive_id: [[user_id, rating], [...], ]
           movie_names_dict is dict of movie_id: movie_title"""

    movies_object_list = []
    for i in range(num_of_movies):
        movies = Movie(i+1)
        movies.movie_title(movie_names_dict)
        movies.movie_ratings_and_average(movie_id_dict)
        movies_object_list.append(movies)
    return movies_object_list
Exemplo n.º 12
0
def getMovieObject(name):
    fileName = name.split(".")[0]
    file = open(name, "r", encoding="UTF8")
    lines = file.readlines()
    file.close()

    temp = ""
    captionList = []
    # 자막 파일 첫줄엔 영화 제목, 자막 딜레이 값이 들어가있다
    first_info = lines[0]
    first_info = first_info.split(',')
    # 영화 한글, 영어 제목 체크
    k_title = first_info[0]
    e_title = first_info[1]
    # 자막 딜레이 체크
    plus_time = int(first_info[2])
    minus_time = int(first_info[3])
    # 영화 포스터 링크
    thumbnail = first_info[4]
    del lines[0]

    for n in lines:
        if n == '\n':
            captionList.append(temp.strip('\n').split("\n"))
            temp = ""
        temp += n

    captionInfoList = []
    for captionInfo in captionList:
        # 자막 넘버
        num = (captionInfo[0].strip(" "))
        # 자막 재생 시간을 구한다
        timeInfo = timeAnalysis(captionInfo[1].strip(" "), plus_time,
                                minus_time)
        # 자막 내용을 구한다
        captionStr = ""
        for temp in captionInfo[2:]:
            captionStr += temp + " "
        caption = captionStr.strip(" ")
        # 자막 리스트에 자막 추가
        captionInfoList.append(CaptionInformation(num, timeInfo, caption))

    # 자막 길이별로 정렬
    captionInfoList.sort(key=lambda x: len(x.caption))

    # 자막에 정규식 패턴 적용
    shortCaptionList = []
    pattern = re.compile('[a-zA-Z. ]+')
    for captionInfo in captionInfoList[math.ceil(len(captionInfoList) / 1.5):]:
        # 정규식 검사
        match = pattern.fullmatch(captionInfo.caption)
        if match:
            # [.] 제거
            captionInfo.caption = captionInfo.caption.replace('.', '')
            shortCaptionList.append(captionInfo)

    movie = Movie(k_title, e_title, shortCaptionList, thumbnail)
    return movie
Exemplo n.º 13
0
 def add_to_db(self):
     ###TODO: Make this work###
     if (main_button.text == "Show"):
         new_release = Show.Show(title.text, director.text,
                                 ep_length.text, ep_count.text)
     elif (main_button.text == "Movie"):
         new_release = Movie.Movie(title.text, director.text,
                                   film_length.text)
     MongoCon.insert(new_release.export())
Exemplo n.º 14
0
class Website():

    #Connection to 'The Movie Database'
    conn = httplib.HTTPConnection('api.themoviedb.org')
    payload = "{}"

    #Request all upcoming movies
    conn.request("GET", "/3/movie/upcoming?page=1&language=en-US&api_key=", payload)

    #Receive results from request
    res = conn.getresponse()

    #Read and format results into objects
    data = res.read()
    obj = json.loads(data)

    movies = []

    #Iterate through results to create instances of the class Movie for each movie returned
    for ka in obj.iteritems():
        if ka[0] == "results":
            for ks in ka[1]:

                #Request trailer for movie
                trailer = ""
                conn.request("GET", "/3/movie/" + str(ks['id']) + "/videos?language=en-US&api_key=", payload)

                #Receive results from request
                res = conn.getresponse()

                #Read and format results into objects
                data = res.read()
                obj = json.loads(data)

                #Create youtube url for 1st trailer
                for la in obj.iteritems():
                    if la[0] == "results":
                        for ls in la[1]:
                            trailer = "https://www.youtube.com/watch?v=" + ls['key']
                            break

                #Generate Movie instance for upcoming movie        
                tempMovie = Movie.Movie(
                    ks['title'],
                    ks['overview'].encode('utf-8'),
                    ks['release_date'],
                    [],
                    [],
                    trailer,
                    "https://image.tmdb.org/t/p/w640" + ks['poster_path'],
                    []
                    )
                movies.append(tempMovie)

    #Pass movie array to fresh_tomatoes
    fresh_tomatoes.open_movies_page(movies)
def main():
    with open(MOVIES_FILE) as data_file:

        # Load JSON data as standard (non unicode) strings.
        movie_data = simplejson.loads(data_file.read())

        # Inflate live Movies from the dicts created from the JSON.
        # Note use of dict unpacking.
        movies = [Movie.Movie(**movie) for movie in movie_data]
        fresh_tomatoes.open_movies_page(movies)
Exemplo n.º 16
0
 def _searchTitles(self,title,limit="1",iteration=0):
     if(title.__len__()<2):
         return ""
     req = urllib.request.Request("http://mymovieapi.com/?type=xml&plot=none&episode=0&yg=0&mt=M&lang=en-US&offset=&aka=simple&release=simple&business=0&tech=0&title="+title+"&limit="+limit,headers={'User-Agent' : ""})
     con = urllib.request.urlopen(req)
     result=con.read()
     i=0
     dom = parseString(result)
     for node in dom.getElementsByTagName("IMDBDocumentList"):
         for node2 in node.getElementsByTagName("title"):
             movie=Movie()
             movie.title=node.getElementsByTagName("title")[i].firstChild.nodeValue
             movie.id=node.getElementsByTagName("imdb_id")[i].firstChild.nodeValue
             movie.rating=node.getElementsByTagName("rating")[i].firstChild.nodeValue
             movie.year=node.getElementsByTagName("year")[i].firstChild.nodeValue
             sonuc=movie
             i=i+1
             return sonuc
         #success
     return self.titleManipulateRight(title,limit,iteration+1)
Exemplo n.º 17
0
def importMovies():
    # Creating movie objects and set their id and title.
    for i in range(0, len(items)):
        tempItem = items[i].split("|")
        if tempItem[0] not in movieList:
            m = Movie()
            m.setId(int(tempItem[0]))
            m.setTitle(tempItem[1])
        movieList[m.getId()] = m
    return movieList
Exemplo n.º 18
0
 def getFilmography(self, profile=DEFAULT_PROFILE):
     url = "http://api.allocine.fr/rest/v3/filmography?partner=%s&code=%s&format=json&profile=%s" % (
         PARTNER_CODE, self.code, profile)
     output = urllib2.urlopen(url).read()
     d = json.loads(output)["person"]["participation"]
     self.__dict__["filmography"] = []
     for i in d:
         if "movie" in i:
             code = i["movie"]["code"]
             i["movie"].pop("code")
             m = Movie.Movie(code, **(i["movie"]))
             self.__dict__["filmography"].append(
                 self.Participation(i["activity"], m))
Exemplo n.º 19
0
def movie():
    if len(movie_list) == 0:
        print("\nNo Movies")
    else:
        print("\nMovies Summary")
        for i in range(len(movie_list)):
            print(
                f"{i+1}.) {movie_list[i].get_movie()} {movie_list[i].get_seats()} seats"
            )
    ans = input(
        "\n     \033[95m(n)ew Movies\n     (d)elete movies\n     (m)ain menu\n     \033[00mChoose a menu : "
    )
    while ans != "m":
        if ans == "n":
            movie = input("\nMovie name : ")
            print("Choose Theater Capacity")
            print(" >>> 100 Seats ")
            print(" >>> 120 Seats ")
            print(" >>> 150 Seats ")
            seats = int(input("Seat capacity : "))
            movie_list.append(Movie(movie, seats))
            remaining_seat.append(seats)
            booking_list.append([[], [], [], []])
            print("\nMovies Summary")
            for i in range(len(movie_list)):
                print(
                    f"{i+1}.) {movie_list[i].get_movie()} {movie_list[i].get_seats()} seats"
                )
            #print(booking_list)
            ans = input(
                "\n     \033[95m(n)ew Movies\n     (d)elete movies\n     (m)ain menu\n     \033[00mChoose a menu : "
            )
            #ans = input("\n     (n)ew Movies\n     (d)elete movies\n     (m)ain menu\n     Choose a menu : ")
        elif ans == "d":
            print("\nMovies Summary")
            for i in range(len(movie_list)):
                print(
                    f"{i+1}.) {movie_list[i].get_movie()} {movie_list[i].get_seats()} seats"
                )
            delete = int(input("\nMovie number : "))
            movie_list.remove(movie_list[delete - 1])
            remaining_seat.remove(remaining_seat[delete - 1])
            print("\nMovies Summary")
            for i in range(len(movie_list)):
                print(
                    f"{i+1}.) {movie_list[i].get_movie()} {movie_list[i].get_seats()} seats"
                )
            ans = input(
                "\n     \033[95m(n)ew Movies\n     (d)elete movies\n     (m)ain menu\n     \033[00mChoose a menu : "
            )
Exemplo n.º 20
0
def loadFile(message, movies):
    filename = input(message + "\n")
    # Use the csv import to read in data from file
    with open(filename, "r") as csv_file:
        csv_reader = csv.reader(csv_file, delimiter=',')
        line_count = 0
        for row in csv_reader:
            if line_count == 0:
                # This line catches the first row with col titles
                line_count += 1
            else:
                # Create a Movie object with data from the CSV
                mov = Movie(row[0], row[1], row[2], row[3], row[4], row[5],
                            row[6], row[7], row[8], row[9])
                movies.append(mov)
                line_count += 1
Exemplo n.º 21
0
def parseMovie(theater_str, input_date, movie_div):
    movie = Movie.Movie()

    movie.showdate = input_date
    movie.theater = THEATERS[theater_str]['full_name']

    # title
    title_h3 = movie_div.find('div', {'class': 'info'}).find('h3')
    year_match = re.search('\((\d+)\)', title_h3.text)
    if year_match is None:
        movie.setTitle(title_h3.text)
    else:
        movie.setTitle(title_h3.text.split('(')[0].strip())
        movie.year = year_match.group(1)

    # url
    url = title_h3.find('a', {'itemprop': 'url'})
    if url is not None:
        movie.show_url = FILM_PAGE_PREFIX + re.search('tt\d+',
                                                      url['href']).group(0)
        movie.imdb_url = movie.show_url

    # directors
    if url is not None:
        movie_page_soup = Common.getPageSoup(movie.show_url)
        if movie_page_soup is not None:
            director_span = movie_page_soup.find('span',
                                                 {'itemprop': 'director'})
            if director_span is not None:
                for director_a in director_span.find_all(
                        'span', {'itemprop': 'name'}):
                    movie.addDirectors(director_a.text)

    # rating
    rating = movie_div.find('strong', {'itemprop': 'ratingValue'})
    if rating is not None and rating.text != '-':
        movie.imdb_rating = float(rating.text)

    # showtimes
    for showtime_a in movie_div.find('div', {
            'class': 'showtimes'
    }).find_all('a', {'rel': 'nofollow'}):
        movie.addShowTime(input_date, showtime_a.text)

    return movie
Exemplo n.º 22
0
    def readTable(self):
        try:
            connection = db.connect('mysql.netsoc.co', 'visrec',
                                    'hFfx3SJcsFUZV', 'visrec_users')
            cursor = connection.cursor(db.cursors.DictCursor)
            cursor.execute("""SELECT * FROM movies""")
            moviesTable = cursor.fetchall()

            for row in moviesTable:
                movieID = row['id']
                movieName = row['name']
                newMovie = Movie(movieID, movieName)
                self.movies[movieID] = newMovie

            cursor.close()
            connection.close()
        except (db.Error, IOError):
            print('Error: reading movies tables.')
Exemplo n.º 23
0
    def get_site(self):
        url = "https://www.imdb.com/search/title/?count=100&groups=top_1000&sort=user_rating"
        response = requests.get(url)
        soup = BeautifulSoup(response.text, 'lxml')

        movies = []
        movie_titles = []
        duration = []
        rating = []
        year = []
        director = []
        number_of_votes = []

        for item in soup.findAll('h3', attrs={'class': 'lister-item-header'}):
            movie_titles.append(item.find('a').contents[0])
        for item in soup.findAll('span', attrs={'class': 'runtime'}):
            duration.append(item.contents[0])
        for item in soup.findAll(
                'div', attrs={'class': 'inline-block ratings-imdb-rating'}):
            rate = float(item.find('strong').contents[0])
            rating.append(rate)
        for item in soup.findAll(
                'span', attrs={'class': 'lister-item-year text-muted unbold'}):
            current_year = item.contents[0].replace('(', '').replace(
                ')', '').replace('I ', '')
            year.append(int(current_year))
        for item in soup.findAll('p', attrs={'class': ''}):
            director.append(item.find('a').contents[0])
        for item in soup.findAll('p',
                                 attrs={'class': 'sort-num_votes-visible'}):
            vote = item.find('span', {
                "name": "nv"
            }).contents[0].replace(',', '')
            vote_number = int(vote)
            number_of_votes.append(vote_number)

        for (title, duration, rating, year, director,
             no_votes) in zip(movie_titles, duration, rating, year, director,
                              number_of_votes):
            movies.append(
                Movie(title, duration, rating, year, director, no_votes))

        return movies
Exemplo n.º 24
0
def read_from_file(filename):
    file = open(filename, "r")
    count = -1
    ## Handle one input line at a time
    for line in file:
        info = line.strip().split("*")
        ## Outputs error if number of values read in is not 4
        if len(info) != 4:
            print(info)
            print("Error: Incorrect number of inputs")
            file.close()
            return None
        movie = Movie(info[0].strip(), info[3].strip(), info[1].strip(),
                      info[2].strip())
        count += 1
        ## Add movies to archive
        if count == 0:
            archive = Archive(movie)
        else:
            archive.addMovie(movie)
    file.close()
    return archive
Exemplo n.º 25
0
def parseMovie(input_date, movie_soup):
    movie = Movie.Movie()
    movie.showdate = input_date

    # title and show link
    title_info = movie_soup.find('h4')
    movie.show_url = title_info.a['href']
    movie.setTitle(title_info.a.text.encode('utf-8'))
    movie.theater = 'Quad Cinema'

    # # showtime
    for showtime_li in movie_soup.find('ul', {
            'class': 'showtimes-list'
    }).findChildren(recursive=False):
        movie.addShowTime(movie.showdate, showtime_li.a.text.replace('.', ':'))

    # director, year (hard to find this one)
    details_soup = Common.getPageSoup(movie.show_url)
    credit_name = details_soup.find('span', {'class': 'credit-name'})
    if credit_name is not None:
        movie.addDirectors(credit_name.text)

    return movie
Exemplo n.º 26
0
    fn = "movie_archive.txt"

    ## Open file and populate archive
    archive = read_from_file(fn)
    if archive == None:
        print("Error: Read Failed")
        sys.exit()
    else:
        ## Will change later to read in the current date
        print("Enter current date:")
        month = input("Month: ")
        day = input("Day: ")
        year = input("Year: ")
        expire = [int(year) - 4, month, day]
        archive.update(expire)

        ## Continues to ask user to input movies until it one is available
        movie_title = input("Request a movie: ")
        movie = Movie(movie_title.strip(), year, month, day)
        added = archive.addMovie(movie)
        while added == False:
            movie_title = input("Request a movie: ")
            movie = Movie(movie_title.strip(), year, month, day)
            added = archive.addMovie(movie)
        print("Added! {} on {}\{}\{}".format(movie_title, month, day, year))

        ## Output archive to new file [We can change this to overwrite the previous file]
        file = open("updated_archive.txt", "w")
        file.write(archive.printA())
        file.close()
Exemplo n.º 27
0
    def createMovie(self, title):

        #         if self.findMovie(title) is not None:
        #             raise ValueError("Movie title already exist.")

        self.movies.append(Movie.movie(title))
Exemplo n.º 28
0
# -*- coding: utf-8 -*-
import argparse

import Movie

FRAME_COUNT = 50

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("movfile_name", help="The input movie file name")
    parser.add_argument("-o",
                        "--output",
                        help="The output directory",
                        default=False)
    parser.add_argument("-n",
                        "--number",
                        help="The number of frames to capture",
                        default=FRAME_COUNT,
                        type=int)
    args = parser.parse_args()

    if args.output:
        movie = Movie.Movie(args.movfile_name, args.output)
    else:
        movie = Movie.Movie(args.movfile_name)

    movie.extract_frames(args.number)
Exemplo n.º 29
0
#import movie_url
#movie_url.get_movie_url(number=120)

import file_operation
import Movie
import connect_mysql

list = file_operation.read_file('movie_url.txt')
path = 'movie_url.txt'
n = 0
for url in list:
    soup = Movie.get_url_html_soup(url)
    id = Movie.get_movie_id(url)
    title = Movie.get_movie_title(soup)
    director = Movie.get_movie_directors(soup)
    screenwriter = Movie.get_movie_screenwriter(soup)
    character = Movie.get_movie_character(soup)
    type = Movie.get_movie_type(soup)
    country = Movie.get_movie_country(soup)
    comment = Movie.get_movie_shortcomment(url)

    connect_mysql.insert_database(id, title, director, screenwriter, character,
                                  type, country)
    connect_mysql.insert_comment(id, comment)
    n = n + 1
    while (n == 10):
        exit()
Exemplo n.º 30
0
    def __init__(self, **kwargs):
        super(Library, self).__init__(**kwargs)

        #class variables

        #class funtions
        def add_to_db(self):
            ###TODO: Make this work###
            if (main_button.text == "Show"):
                new_release = Show.Show(title.text, director.text,
                                        ep_length.text, ep_count.text)
            elif (main_button.text == "Movie"):
                new_release = Movie.Movie(title.text, director.text,
                                          film_length.text)
            MongoCon.insert(new_release.export())

        def batch_add(self):
            sm.current = 'batch'

        main_layout = BoxLayout(padding=10, orientation="horizontal")
        self.add_widget(main_layout)
        list_layout = BoxLayout(padding=5, orientation="vertical")
        input_layout = BoxLayout(padding=5, orientation="vertical")
        input_layout.add_widget(Label(text="Type"))
        #Dropdown doesn't actually select anything yet
        dropdown = DropDown()
        show_btn = Button(text="Show", size_hint_y=None, height=45)
        show_btn.bind(
            on_release=lambda show_btn: dropdown.select(show_btn.text))
        movie_btn = Button(text="Movie", size_hint_y=None, height=45)
        movie_btn.bind(
            on_release=lambda movie_btn: dropdown.select(movie_btn.text))
        main_button = Button(text="Choose Type", size_hint=(None, None))
        main_button.bind(on_release=dropdown.open)
        dropdown.bind(
            on_select=lambda instance, x: setattr(main_button, 'text', x))
        dropdown.add_widget(show_btn)
        dropdown.add_widget(movie_btn)
        input_layout.add_widget(main_button)
        #        input_layout.add_widget(dropdown)
        input_layout.add_widget(Label(text='Title'))
        title = TextInput(mutliline=False)
        input_layout.add_widget(title)
        input_layout.add_widget(Label(text="Director"))
        director = TextInput(multiline=False)
        input_layout.add_widget(director)
        input_layout.add_widget(Label(text="Episode Length"))
        ep_length = TextInput(multiline=False)
        input_layout.add_widget(ep_length)
        input_layout.add_widget(Label(text="Film Length"))
        film_length = TextInput(multiline=False)
        input_layout.add_widget(film_length)
        input_layout.add_widget(Label(text="Episode Count"))
        ep_count = TextInput(multiline=False)
        input_layout.add_widget(ep_count)
        add_button = Button(text="Add Release")
        add_button.bind(on_press=add_to_db)
        input_layout.add_widget(add_button)
        batch_button = Button(text="Batch Add")
        batch_button.bind(on_press=batch_add)
        input_layout.add_widget(batch_button)

        #Just run locally on a test instance
        host = "mongodb://localhost:27017"
        dbname = "releases"
        col = "my_collection"
        MongoCon = mongo.MongoCon(host, dbname, col)
        #Populate with any existing items from the db
        records = MongoCon.selectAll()
        release_list = []
        if (records):
            for release in records:
                #Records can either be of type show or movie. Certain data is required, otherwise check for it and add if present
                if (release["type"] == "show"):
                    ReleaseObj = Show.Show(release["title"],
                                           release["director"],
                                           release["ep_length"],
                                           release["episodes"])
                elif (release["type"] == "movie"):
                    ReleaseObj = Movie.Movie(release["title"],
                                             release["director"],
                                             release["length"])
                if ("actors" in release):
                    ReleaseObj.setActors(release["actors"])
                if ("year" in release):
                    ReleaseObj.setYear(release["year"])
                if ("publisher" in release):
                    ReleaseObj.setPublisher(release["publisher"])
                release_list.append(ReleaseObj)

        #Create a list of titles in the db to display
        list_of_titles = ''
        for ReleaseObj in release_list:
            list_of_titles += ReleaseObj.getName() + "\n"
        list_layout.add_widget(Label(text=list_of_titles))
        main_layout.add_widget(list_layout)
        main_layout.add_widget(input_layout)
Exemplo n.º 31
0
import kivy
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.textinput import TextInput
from kivy.uix.dropdown import DropDown
from kivy.uix.button import Button
from kivy.base import runTouchApp
from kivy.lang import Builder
from kivy.uix.screenmanager import ScreenManager, Screen

sm = ScreenManager()

#Test the Show and Movie classes with test data
steinsgate = Show.Show("Steins;Gate", "Hiroshi Hamasaki", 30, 26)
boyandbeast = Movie.Movie("The Boy and the Beast", "Mamoru Hosoda", 120)
steinsgate.setYear(2011)
steinsgate.setActors(["J. Michael Tatum", "Caitlin Glass"])
steinsgate.setActors(["Ashly Burch"])

# Builder.load_string("""
# <Library>:
#     BoxLayout:
#         Button:
#             text: 'Go to batch'
#             on_press: root.manager.current = 'batch'
# <Batch>:
#     BoxLayout:
#         Button:
#             text: 'Back to Library'
#             on_press: root.manager.current = 'library'
Exemplo n.º 32
0
'''
Ryan Schachte
Favorite Movies
Add list of favorite movies and play trailer of desired movie.
Tests OOP skills and foundations
'''
import Movie
import fresh_tomatoes

#Some Test Movies
avatar = Movie.MovieInformation(
    "Avatar", "Avatar Description",
    "http://www.arts-wallpapers.com/movie_posters/movie-posters-november-2009/images/Movie%20Posters%20November%202009_03.jpg",
    "http://www.youtube.com/watch?v=d1_JBMrrYw8")
hours = Movie.MovieInformation(
    "127 Hours", "127 Hours Description",
    "http://gdj.gdj.netdna-cdn.com/wp-content/uploads/2011/03/127-hours-movie-poster.jpg",
    "http://www.youtube.com/watch?v=OlhLOWTnVoQ")
virgin = Movie.MovieInformation(
    "40 Yearold Virgin", "Virgin Description",
    "http://blog.calindaniel.com/wp-content/uploads/2010/07/40-year-old-virgin-poster1.jpg",
    "http://www.youtube.com/watch?v=Vn3IRHhPXMo")

#List to contain all movies added
movies = [avatar, hours, virgin]

fresh_tomatoes.open_movies_page(movies)
Exemplo n.º 33
0
 def produceMovie(self, *extractionParams):
     movieargs = []
     for paramValue in extractionParams:
         extracted = self.browser.getByXpath(paramValue)
         movieargs.append(extracted)
     return Movie.Movie(*movieargs)