Example #1
0
 def test_get_tibia_url(self):
     self.assertEqual(
         "https://www.tibia.com/community/?subtopic=character&name=Galarzaa+Fidera",
         get_tibia_url("community", "character", name="Galarzaa Fidera"))
     self.assertEqual(
         "https://www.tibia.com/community/?subtopic=character&name=Fn%F6",
         get_tibia_url("community", "character", name="Fnö"))
Example #2
0
    def get_url(cls,
                *,
                vocation=None,
                group=None,
                spell_type=None,
                premium=None,
                sort=None):
        """Get the URL to the spells section with the desired filtering parameters.

        Parameters
        ----------
        vocation: :class:`VocationSpellFilter`, optional
            The vocation to filter in spells for.
        group: :class:`SpellGroup`, optional
            The spell's primary cooldown group.
        spell_type: :class:`SpellType`, optional
            The type of spells to show.
        premium: :class:`bool`, optional
            The type of premium requirement to filter. :obj:`None` means any premium requirement.
        sort: :class:`SpellSorting`, optional
            The field to sort spells by.

        Returns
        -------
        :class:`str`
            The URL to the spells section with the provided filtering parameters.
        """
        params = {
            "vocation": vocation.value if vocation else None,
            "group": group.value if group else None,
            "type": spell_type.value if spell_type else None,
            "sort": sort.value if sort else None,
            "premium": to_yes_no(premium),
        }
        return get_tibia_url("library", "spells", **params)
Example #3
0
    def get_url(cls, world, rotation_id=None, page=1):
        """Get the URL to the leaderboards of a world.

        Parameters
        ----------
        world: :class:`str`
            The desired world.
        rotation_id: :class:`int`
            The ID of the desired rotation. If undefined, the current rotation is shown.
        page: :class:`int`
            The desired page. By default, the first page is returned.

        Returns
        -------
        :class:`str`
            The URL to the leaderboard with the desired parameters.

        Raises
        ------
        ValueError
            If the specified page is zer or less.
        """
        if page <= 0:
            raise ValueError("page must be 1 or greater")
        return get_tibia_url("community",
                             "leaderboards",
                             world=world,
                             rotation=rotation_id,
                             currentpage=page)
Example #4
0
    def get_url(cls, start_date, end_date, page=1):
        """Gets the URL to the CM Post Archive for the given date range.

        Parameters
        ----------
        start_date: :class: `datetime.date`
            The start date to display.
        end_date: :class: `datetime.date`
            The end date to display.
        page: :class:`int`
            The desired page to display.

        Returns
        -------
        :class:`str`
            The URL to the CM Post Archive

        Raises
        ------
        TypeError:
            Either of the dates is not an instance of :class:`datetime.date`
        ValueError:
            If ``start_date`` is more recent than ``end_date``.
        """
        if not isinstance(start_date, datetime.date):
            raise TypeError(f"start_date: expected datetime.date instance, {type(start_date)} found.")
        if not isinstance(end_date, datetime.date):
            raise TypeError(f"start_date: expected datetime.date instance, {type(start_date)} found.")
        if end_date < start_date:
            raise ValueError("start_date can't be more recent than end_date.")
        if page < 1:
            raise ValueError("page must be 1 or greater.")
        return get_tibia_url("forum", "forum", action="cm_post_archive", startday=start_date.day,
                             startmonth=start_date.month, startyear=start_date.year, endday=end_date.day,
                             endmonth=end_date.month, endyear=end_date.year, currentpage=page)
Example #5
0
    def get_url(cls,
                world=None,
                category=Category.EXPERIENCE,
                vocation=VocationFilter.ALL,
                page=1):
        """Gets the Tibia.com URL of the highscores for the given parameters.

        Parameters
        ----------
        world: :class:`str`
            The game world of the desired highscores. If no world is passed, ALL worlds are shown.
        category: :class:`Category`
            The desired highscores category.
        vocation: :class:`VocationFiler`
            The vocation filter to apply. By default all vocations will be shown.
        page: :class:`int`
            The page of highscores to show.

        Returns
        -------
        The URL to the Tibia.com highscores.
        """
        if world is None:
            world = "ALL"
        return get_tibia_url("community",
                             "highscores",
                             world=world,
                             category=category.value,
                             profession=vocation.value,
                             currentpage=page)
Example #6
0
    def get_url(cls, world=None, category=Category.EXPERIENCE, vocation=VocationFilter.ALL, page=1,
                battleye_type=None, pvp_types=None):
        """Get the Tibia.com URL of the highscores for the given parameters.

        Parameters
        ----------
        world: :class:`str`, optional
            The game world of the desired highscores. If no world is passed, ALL worlds are shown.
        category: :class:`Category`
            The desired highscores category.
        vocation: :class:`VocationFilter`
            The vocation filter to apply. By default all vocations will be shown.
        page: :class:`int`
            The page of highscores to show.
        battleye_type: :class:`BattlEyeHighscoresFilter`, optional
            The battleEye filters to use.
        pvp_types: :class:`list` of :class:`PvpTypeFilter`, optional
            The list of PvP types to filter the results for.

        Returns
        -------
        The URL to the Tibia.com highscores.
        """
        pvp_types = pvp_types or []
        pvp_params = [("worldtypes[]", p.value) for p in pvp_types]
        return get_tibia_url("community", "highscores", *pvp_params, world=world, category=category.value,
                             profession=vocation.value, currentpage=page,
                             beprotection=battleye_type.value if battleye_type else None)
Example #7
0
    def get_support_boards_url(cls):
        """Get the URL to the Support Boards section in Tibia.com.

        Returns
        -------
        :class:`str`:
            The URL to the Support Boards.
        """
        return get_tibia_url("forum", "supportboards")
Example #8
0
    def get_community_boards_url(cls):
        """Get the URL to the Community Boards section in Tibia.com.

        Returns
        -------
        :class:`str`:
            The URL to the Community Boards.
        """
        return get_tibia_url("forum", "communityboards")
Example #9
0
    def get_trade_boards_url(cls):
        """Get the URL to the Trade Boards section in Tibia.com.

        Returns
        -------
        :class:`str`:
            The URL to the Trade Boards.
        """
        return get_tibia_url("forum", "tradeboards")
Example #10
0
    def get_world_boards_url(cls):
        """Get the URL to the World Boards section in Tibia.com.

        Returns
        -------
        :class:`str`:
            The URL to the World Boards.
        """
        return get_tibia_url("forum", "worldboards")
Example #11
0
    def get_url(cls):
        """Get the URL to the Tibia.com library section.

        Returns
        -------
        :class:`str`:
            The URL to the Tibia.com library section.
        """
        return get_tibia_url("library", "creature")
Example #12
0
    def get_url(cls):
        """Get the URL to the World Overview page in Tibia.com.

        Returns
        -------
        :class:`str`
            The URL to the World Overview's page.
        """
        return get_tibia_url("community", "worlds")
Example #13
0
    def get_url(cls, name):
        """Gets the Tibia.com URL for a given character name.

        Parameters
        ------------
        name: :class:`str`
            The name of the character.

        Returns
        --------
        :class:`str`
            The URL to the character's page."""
        return get_tibia_url("community", "characters", name=name)
Example #14
0
    def get_url(cls, news_id):
        """Gets the Tibia.com URL for a news entry by its id.

        Parameters
        ------------
        news_id: :class:`int`
            The id of the news entry.

        Returns
        --------
        :class:`str`
            The URL to the news' page"""
        return get_tibia_url("news", "newsarchive", id=news_id)
Example #15
0
    def get_url(cls, world):
        """Get the Tibia.com URL of the kill statistics of a world.

        Parameters
        ----------
        world: :class:`str`
            The game world of the desired kill statistics.

        Returns
        -------
        The URL to the Tibia.com kill statistics for this world.
        """
        return get_tibia_url("community", "killstatistics", world=world)
Example #16
0
    def get_world_list_url(cls, world):
        """Gets the Tibia.com URL for the guild section of a specific world.

        Parameters
        ----------
        world: :class:`str`
            The name of the world.

        Returns
        -------
        :class:`str`
            The URL to the guild's page
        """
        return get_tibia_url("community", "guilds", world=world)
Example #17
0
    def get_url(cls, announcement_id):
        """Get the URL to an announcement with a given ID.

        Parameters
        ----------
        announcement_id: :class:`int`
            The ID of the announcement

        Returns
        -------
        :class:`str`
            The URL of the announcement.
        """
        return get_tibia_url("forum", None, action="announcement", announcementid=announcement_id)
Example #18
0
    def get_url(cls, identifier):
        """Get the URL to a spell in the Tibia.com spells section.

        Parameters
        ----------
        identifier: :class:`str`
            The identifier of the spell.

        Returns
        -------
        :class:`str`
            The URL to the spell.
        """
        return get_tibia_url("library", "spells", spell=identifier.lower())
Example #19
0
    def get_url(cls, name):
        """Gets the URL to the World's information page on Tibia.com.

        Parameters
        ----------
        name: :class:`str`
            The name of the world.

        Returns
        -------
        :class:`str`
            The URL to the world's information page.
        """
        return get_tibia_url("community", "worlds", world=name.title())
Example #20
0
    def get_url(cls, identifier):
        """Get the URL to the creature's detail page on Tibia.com.

        Parameters
        ----------
        identifier: :class:`str`
            The race's internal name.

        Returns
        -------
        :class:`str`
            The URL to the detail page.
        """
        return get_tibia_url("library", "creatures", race=identifier)
Example #21
0
    def get_url(cls):
        """Get the URL to Tibia.com's news archive page.

        Notes
        -----
        It is not possible to perform a search using query parameters.
        News searches can only be performed using POST requests sending the parameters as form-data.

        Returns
        -------
        :class:`str`
            The URL to the news archive page on Tibia.com.
        """
        return get_tibia_url("news", "newsarchive")
Example #22
0
    def get_url(cls, name):
        """Get the Tibia.com URL for a given guild name.

        Parameters
        ------------
        name: :class:`str`
            The name of the guild.

        Returns
        --------
        :class:`str`
            The URL to the guild's page.
        """
        return get_tibia_url("community", "guilds", page="view", GuildName=name)
Example #23
0
    def get_url(cls, post_id):
        """Get the URL to a specific post.

        Parameters
        ----------
        post_id: :class:`int`
            The ID of the desired post.

        Returns
        -------
        :class:`str`
            The URL to the post.
        """
        return get_tibia_url("forum", None, anchor=f"post{post_id}", action="thread", postid=post_id)
Example #24
0
    def get_url(cls, house_id, world):
        """Get the Tibia.com URL for a house with the given id and world.

        Parameters
        ----------
        house_id: :class:`int`
            The internal id of the house.
        world: :class:`str`
            The world of the house.

        Returns
        -------
        The URL to the house in Tibia.com
        """
        return get_tibia_url("community", "houses", page="view", houseid=house_id, world=world)
Example #25
0
    def get_url(cls, thread_id, page=1):
        """Get the URL to a thread with a given id.

        Parameters
        ----------
        thread_id: :class:`int`
            The id of the desired thread.
        page: :class:`int`
            The desired page, by default 1.

        Returns
        -------
        :class:`str`
            The URL to the thread.
        """
        return get_tibia_url("forum", None, action="thread", threadid=thread_id, pagenumber=page)
Example #26
0
    def get_url_wars(cls, name):
        """Get the Tibia.com URL for the guild wars of a guild with a given name.

        .. versionadded:: 3.0.0

        Parameters
        ------------
        name: :class:`str`
            The name of the guild.

        Returns
        --------
        :class:`str`
            The URL to the guild's wars page.
        """
        return get_tibia_url("community", "guilds", page="guildwars", action="view", GuildName=name)
Example #27
0
    def get_url(cls, board_id, page=1, age=30):
        """Get the Tibia.com URL to a board with a given id.

        Parameters
        ----------
        board_id: :class:`int`
            The ID of the board.
        page: :class:`int`
            The page to go to.
        age: :class:`int`
            The age in days of the threads to display.

        Returns
        -------
        :class:`str`
            The URL to the board.
        """
        return get_tibia_url("forum", None, action="board", boardid=board_id, pagenumber=page, threadage=age)
Example #28
0
    def get_url(cls, world, tournament_cycle, page=1):
        """Gets the URL to the leaderboards of a specific world, tournament and page.

        Parameters
        ----------
        world: :class:`str`
            The world to get the leaderboards for.
        tournament_cycle: :class:`int`
            The cycle of the tournament to get the leaderboards for.
        page: :class:`int`
            The leader board's page to view. By default 1.

        Returns
        -------
        The URL to the specified leaderboard.
        """
        return get_tibia_url("community", "tournamentleaderboards", tournamentworld=world,
                             tournamentcycle=tournament_cycle, selectedleaderboardpage=page)
Example #29
0
    def get_url(cls, tournament_cycle):
        """Gets the URL to a tournament's information page if its cycle is provided,
        otherwise it shows the current tournament.

        Parameters
        ----------
        tournament_cycle: :class:`int`
            The tournament's cycle.

        Returns
        -------
        :class:`str`
            The URL to the specified tournament.
        """
        params = None
        if tournament_cycle:
            params = {
                "tournamentcycle": tournament_cycle,
                "action": "archive",
            }
        return get_tibia_url("community", "tournament", **params)
Example #30
0
    def get_url(cls, month=None, year=None):
        """Gets the URL to the Event Schedule or Event Calendar on Tibia.com

        Notes
        -----
        If no parameters are passed, it will show the calendar for the current month and year.

        Tibia.com limits the dates that the calendar displays, passing a month and year far from the current ones may
        result in the response being for the current month and year instead.

        Parameters
        ----------
        month: :class:`int`, optional
            The desired month.
        year: :class:`int`, optional
            The desired year.

        Returns
        -------
        :class:`str`
            The URL to the calendar with the given parameters.
        """
        return get_tibia_url("news", "eventcalendar", calendarmonth=month, calendaryear=year)