Exemplo n.º 1
0
    def _get_categories():
        """
        Get all movie categories from website.
        :return: dict
        """

        html = getHTML(SledujuFilmy.URL)

        # List of categories
        categories = []

        # Find all category links from home page
        if html:
            links = html.find(id="content").find(class_="genres").find_all("a")

            for link in links:
                if link.get("href"):
                    # And save them into list
                    categories.append({
                        "url":
                        urlparse.urljoin(SledujuFilmy.URL, link["href"]),
                        "name":
                        link.string
                    })

        return categories
Exemplo n.º 2
0
    def _get_latest():
        """
        Get list of latest added movies. Cached version. See `_get_movies_from_list` for format.
        :return: list
        """

        html = getHTML(SledujuFilmy.URL)

        if html:
            latest_movies = html.find(id="content").find(
                class_="riding-list").find_all("div", class_="item")
            return SledujuFilmy._get_movies_from_list(latest_movies)

        return []
def select_source(request):

    # Show informative dialog and get sources in background
    progress = xbmcgui.DialogProgress()
    # Searching, please stand by
    progress.create(xbmcaddon.Addon().getLocalizedString(30002),
                    xbmcaddon.Addon().getLocalizedString(30003))
    players_html = getHTML(
        "http://stream-a-ams1xx2sfcdnvideo5269.cz/okno.php?movie=%s=&new_way" %
        (request.query("id")))
    progress.update(50)
    sources = SledujuFilmy.getMovieSources(players_html)
    progress.close()
    del progress

    if sources is None:
        # No sources, sorry
        xbmcgui.Dialog().notification(
            xbmcaddon.Addon().getLocalizedString(30017),
            xbmcaddon.Addon().getLocalizedString(30018),
        )
        return

    # Prepare source selection
    menu_items = []
    url_items = []
    for source in sources:
        menu_items.append(source["server"])
        url_items.append(source["source"])

    result = xbmcgui.Dialog().select(
        xbmcaddon.Addon().getLocalizedString(30004), menu_items)

    # Show informative dialog and resolve URL in background
    progress = xbmcgui.DialogProgress()
    # Contacting server, stand by
    progress.create(xbmcaddon.Addon().getLocalizedString(30005),
                    xbmcaddon.Addon().getLocalizedString(30006))
    resolved = SledujuFilmy.resolveMovieLink(url_items[result])
    progress.close()
    del progress

    if resolved:
        xbmc.executebuiltin("PlayMedia(%s, False, 0)" % (resolved))
    else:
        # Error, could not connect
        xbmcgui.Dialog().notification(
            xbmcaddon.Addon().getLocalizedString(30007),
            xbmcaddon.Addon().getLocalizedString(30008))
Exemplo n.º 4
0
    def _get_category_movies(categoryUrl, page):
        """
        Get list of all movies from selected category and page. See `_get_movies_from_list` for format.
        :param categoryUrl: Full link to category main page.
        :param page: Page number used for pagination.
        :return: dict
        """
        html = getHTML(
            urlparse.urljoin(
                categoryUrl,
                "?" + urllib.urlencode({"pg": page}) if page > 1 else ""))

        if html:
            category_movies = html.find(id="content").find(
                class_="riding-list").find_all("div", class_="item")
            return SledujuFilmy._get_movies_from_list(category_movies)

        return []
Exemplo n.º 5
0
    def _search(name):
        """
        Search movie by name. Return empty array or list. See `_get_movies_from_list` for format.
        :param name: Movie name, or its part.
        :return: list
        """
        html = getHTML(
            urlparse.urljoin(
                SledujuFilmy.URL,
                "vyhledavani/?" + urllib.urlencode({"search": name})))

        if html:
            # Nothing was found for that search
            if html.find("div", class_="flash_message"):
                return []

            items = html.find("div",
                              class_="mlist--list").find_all("div",
                                                             class_="item")
            return SledujuFilmy._get_movies_from_list(items)

        return []
Exemplo n.º 6
0
    def _get_movies_from_list(list):
        """
        Parse list of movies in HTML into PHP dictionary. On background, movie profile is visited for scrapping more
        information. This may take a while!

        **Format:**

            {
                "name": "Movie name",
                "description": "Long movie description (if found)",
                "rating": "CSFD rating from 0 to 10),
                "image": "Movie poster. Small size",
                "actors": "List of actors",
                "views": "Number of views on SledujuFilmy.cz",
                "length": "Length in minutes",
                "origin": "Country of movie origin",
                "release": "Release year",
                "gendres": "List of movie gendres",
                "id", "Movie ID for players scrappers. See getMovieSources()"
            }

        :param list: HTML with list of movies
        :return: dict
        """

        listOfMovies = []

        for movie in list:
            profile = getHTML(SledujuFilmy._get_movie_profile_url(movie))

            if profile:
                ratingText = profile.find("div", class_="rating").find(
                    "div", class_="csfd").contents[0].strip()
                rating = round(
                    int(ratingText[:ratingText.find(" ") + 1]) / 10, 1)

                actors = SledujuFilmy._get_movie_actors(profile)
                data = SledujuFilmy._get_movie_data_chunks(profile)

                movieId = profile.find("div", id="play_block").find(
                    "a", class_="play-movie")["data-loc"]

                description = profile.find(
                    "p", id="movie_description").contents[1].string.strip()
                if "/" == description:
                    description = xbmcaddon.Addon().getLocalizedString(30001)

                listOfMovies.append({
                    "name":
                    SledujuFilmy._get_movie_name(profile),
                    "description":
                    description,
                    "rating":
                    rating,
                    "image":
                    SledujuFilmy._get_movie_icon(movie),
                    "actors":
                    actors,
                    "views":
                    int(
                        profile.find("div", class_="rating").find(
                            "div", class_="views").find("div").string),
                    "length":
                    data["length"] if data else "",
                    "origin":
                    data["origin"] if data else "",
                    "release":
                    data["release"] if data else "",
                    "gendres":
                    data["gendres"] if data else "",
                    "id":
                    movieId
                })

        return listOfMovies