Beispiel #1
0
def month(day_time=None):
    base_url = f"{BASE_URL}&termGbn=month"  # noqa
    local_dt = utils.localize_time(day_time, TIMEZONE)
    months = utils.get_months(local_dt)
    years = utils.get_years(local_dt)
    url = f"{base_url}&targetTime={months}&hitYear={years}"
    return utils.get_ranks(url, SELECTOR, parser)
Beispiel #2
0
def week(day_time=None):
    base_url = f"{BASE_URL}&termGbn=week"  # noqa
    local_dt = utils.localize_time(day_time, TIMEZONE)
    weeks = utils.get_weeks(local_dt)
    years = utils.get_years(local_dt)
    url = f"{base_url}&targetTime={weeks}&hitYear={years}"
    return utils.get_ranks(url, SELECTOR, parser)
Beispiel #3
0
def day(day_time=None):
    base_url = f"{BASE_URL}/d"
    local_dt = utils.localize_time(day_time, TIMEZONE)
    url = utils.append_date_string(base_url,
                                   local_dt,
                                   date_format="%Y-%m-%d",
                                   trailing_slash=True)
    return utils.get_ranks(url, SELECTOR, parser)
Beispiel #4
0
def year(day_time=None):
    base_url = f"{BASE_URL}/y"
    local_dt = utils.localize_time(day_time, TIMEZONE)
    beg, _ = utils.get_week_dates(local_dt)
    url = utils.append_date_string(base_url,
                                   local_dt,
                                   date_format="%Y",
                                   trailing_slash=True)
    return utils.get_ranks(url, SELECTOR, parser)
Beispiel #5
0
def trend(day_time=None):
    """Get latest trending ranks.

    NOTE: Historical value refreshes daily.
    """
    base_url = f"{BASE_URL}/rise/index.htm"
    local_dt = utils.localize_time(day_time, "Asia/Seoul")
    url = utils.append_date_string(
        base_url, local_dt, date_key="dayTime", date_format="%Y%m%d%H")
    return utils.get_ranks(url, SELECTOR, parser)
Beispiel #6
0
def month(day_time=None):
    """Return rankings for given month."""
    url = f"{BASE_URL}&duration=28d"
    if day_time is not None:
        base_url = "https://music.naver.com/listen/history/index.nhn?type=TOTAL"

        local_dt = utils.localize_time(day_time, TIMEZONE)
        year = local_dt.strftime("%Y")
        month = local_dt.strftime("%m")
        # 0 == all, so the first week is 1.
        week = 0

        url = f"{base_url}&year={year}&month={month}&week={week}"

    return utils.get_ranks(url, SELECTOR, parser)
Beispiel #7
0
def year(day_time=None):
    local_dt = utils.localize_time(day_time, TIMEZONE)
    url = utils.append_date_string(BASE_URL, local_dt, date_format="%Y")
    return utils.get_ranks(url, SELECTOR, parser)
Beispiel #8
0
def week(day_time=None):
    local_dt = utils.localize_time(day_time, TIMEZONE)
    beg, end = utils.get_week_dates(local_dt)
    date_format = "%Y%m%d"
    url = f"{BASE_URL}/{beg.strftime(date_format)}-{end.strftime(date_format)}"
    return utils.get_ranks(url, SELECTOR, parser)