def __get_post_info(self, fpt_post):
        try:
            post_title = scraper_lib.Element(block=fpt_post,
                                             el_tag="h5",
                                             el_class="titleFilm",
                                             get_text=True).get_element()
        except:
            post_title = scraper_lib.Element(block=fpt_post,
                                             el_tag="h2",
                                             el_class="titleFilm",
                                             get_text=True).get_element()

        post_ref_url = scraper_lib.Element(block=fpt_post,
                                           el_tag="a",
                                           el_property="href").get_element()

        try:
            image = scraper_lib.Element(
                block=fpt_post,
                el_tag="img",
                el_class="attachment-loc-film size-loc-film wp-post-image",
                el_property="src").get_element()
        except:
            image = "n.d."

        movie = Movie(title=post_title, page_url=post_ref_url)
        movie.image_url = image
        return movie
    def get_search_result(self, keyword):
        movies_list = []
        raw_keyword = keyword
        keyword = raw_keyword.replace(" ", "+")
        search_result = scraper_lib.get_page_soup(url=self.search_url.format(
            self.domain, keyword),
                                                  check_result=True)

        if (search_result == -1):
            result_url = self.get_movie_url_from_google(keyword)
            search_result = scraper_lib.get_page_soup(url=result_url)

        movies = scraper_lib.Container(
            block=search_result,
            tag='div',
            container_class='col-lg-3 col-md-4 col-xs-4 mb-30').get_container(
            )

        for movie in movies:
            movies_list.append(self.__get_post_info(movie))

        if (not movies_list):
            try:
                title = scraper_lib.Element(block=search_result,
                                            el_tag='title',
                                            get_text=True).get_element()
            except:
                title = raw_keyword

            movie = Movie(title=title, page_url=result_url)
            movie.image_url = "n.d."
            movies_list.append(movie)

        return movies_list
    def _get_movie_result(self, tmdb_url):
        result = requests.get(tmdb_url).json()
        movies = []
        for x in result["results"]:
            movie = Movie(title=x["title"])
            movie.overview = x["overview"]
            movie.release_date = x.get("release_date", '-').split('-')[0]
            movie.image_url = x["poster_path"]
            movies.append(movie)

        return movies
    def get_post_info(self, fpt_post, media_type):
        post_title = scraper_lib.Element(block=fpt_post, el_tag="div",
            el_class="title", get_text=True).get_element()
        
        post_ref_url = scraper_lib.Element(block=fpt_post, el_tag="a",
            el_property="href").get_element()

        image = scraper_lib.Element(block=fpt_post, el_tag="a",
            el_property="data-thumbnail").get_element()

        if media_type == "movie":
            movie = Movie(title=post_title, page_url=post_ref_url)
            movie.image_url = image
            return movie
        else:
            tvshow = TvShow(title=post_title, page_url=post_ref_url)
            tvshow.image_url = image
            return tvshow
Beispiel #5
0
def load_movies_from_json():
    json_path = os.path.dirname(os.path.realpath(__file__))
    json_fullname = json_path + "/example.json"
    movies = []
    with open(json_fullname) as json_file:
        data = json.load(json_file)
        for json_movie in data["movies"]:
            movie = Movie(title=json_movie["title"], urls=json_movie["url"])
            movies.append(movie)
    return movies
 def get_players(self, title, hdpass_iframe_url):
     hdload = HDLoad(hdpass_iframe_url)
     players = hdload.get_all_players()
     return Movie(title=title, page_url=hdpass_iframe_url, urls=players)
    def get_movie(self, title, fpt_movie_url):
        self.soup = scraper_lib.get_page_soup(fpt_movie_url)
        urls = self.__get_movies_url()

        movie = Movie(title, urls)
        return movie