Помощь

nnplayer

Известный
Автор темы
47
7
Я хотел сделать новый интерфейс для радио, но в cef нету названий песен. Может у кого то есть идея, как достать все названия песен и совместить с ид
 

jurdy777

Участник
126
17

nnplayer

Известный
Автор темы
47
7
ты походу это имел ввиду: https://gtaradio.net/ru/sa
нет, я хотел сделать mimgui меню которое включает треки из AZpotify(именно чтобы в игре все слышали). Я разобрался как включать треки и какая функция для этого надо, но там только ИД песен. То есть я по факту имею 600+ ид, но нету названий этих треков
 
Последнее редактирование:

БеzликиЙ

Эксперт в области Аризона РПГ
Проверенный
1,996
1,184
там весело пиздец:

Начнём со списка жанров, который захардкожен в frontend:
Жанры - строки 125301~125320:
var constants_Genres = {
  Top: 'top',
  Pop: 'pop',
  Indie: 'indie',
  Rnb: 'rnb',
  Electro: 'electronic',
  Classic: 'classic',
  Phonk: 'phonk',
  Rock: 'rock',
  Jazz: 'jazz',
  Chanson: 'chanson',
  Rap: 'rap',
  Country: 'country',
  Delorenzy: 'delorenzy',
  Nfs: 'nfs',
  Fm: 'radio',
  Favorites: 'favorites'
};
var GENRES_TO_VIEW = [constants_Genres.Top, constants_Genres.Pop, constants_Genres.Indie, constants_Genres.Rnb, constants_Genres.Electro, constants_Genres.Classic, constants_Genres.Phonk, constants_Genres.Rock, constants_Genres.Jazz, constants_Genres.Chanson, constants_Genres.Rap, constants_Genres.Delorenzy, constants_Genres.Nfs, constants_Genres.Fm];
var azpotify_constants_MAP_GENRE_TO_ICON = (constants_MAP_GENRE_TO_ICON = {}, azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(constants_MAP_GENRE_TO_ICON, constants_Genres.Top, 'lightning'), constants_Genres.Pop, 'microphone'), constants_Genres.Indie, 'ukulele'), constants_Genres.Rnb, 'cloud-melody'), constants_Genres.Electro, 'disk'), constants_Genres.Classic, 'harp'), constants_Genres.Phonk, 'phonk'), constants_Genres.Rock, 'rock'), constants_Genres.Jazz, 'trumpet'), constants_Genres.Chanson, 'glock'), azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(constants_MAP_GENRE_TO_ICON, constants_Genres.Rap, 'rip'), constants_Genres.Country, 'cowboy'), constants_Genres.Delorenzy, 'delorenzy'), constants_Genres.Nfs, 'race-flag'), constants_Genres.Fm, 'fm'), constants_Genres.Favorites, 'azpotify-like-filled'));
var azpotify_constants_MAP_GENRE_TO_NAME = (constants_MAP_GENRE_TO_NAME = {}, azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(constants_MAP_GENRE_TO_NAME, constants_Genres.Top, 'Топ 100'), constants_Genres.Pop, 'Поп'), constants_Genres.Indie, 'Инди'), constants_Genres.Rnb, 'RnB'), constants_Genres.Punk, 'Панк'), constants_Genres.Electro, 'Электроника'), constants_Genres.Classic, 'Классическая'), constants_Genres.Phonk, 'Phonk'), constants_Genres.Rock, 'Рок'), constants_Genres.Jazz, 'Джаз/Кантри'), azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(constants_MAP_GENRE_TO_NAME, constants_Genres.Chanson, 'Шансон'), constants_Genres.Rap, 'Реп и хип-хоп'), constants_Genres.Country, 'Кантри'), constants_Genres.Nfs, 'NFS'), constants_Genres.Fm, 'Радио'), constants_Genres.Delorenzy, 'Delorenzy'), constants_Genres.Favorites, 'Избранное'));
Тебя интересует в первую очередь constants_Genres - это словарь строк, каждая из которых является параметром HTTP-запроса.
Дальше: endpoint, к которому обращается сам клиент, чтобы получать треки по этим жанрам:
125330 ~ 125334:
var constants_API_URL = {
  GetByGenre: '/client/azpotify/v3/az-spotify/getByCategorie',
  GetByName: '/client/azpotify/v1/az-spotify-v2/search',
  GetByIDs: '/client/azpotify/v1/az-spotify-v2/getFavorites'
};
var GetUrlAPI = function GetUrlAPI(route) {
  return "".concat(SERVER_API_URL).concat(route);
};

При получении списка треков по жанру мы обращаемся к ${SERVER_API_URL}/client/azpotify/v3/az-spotify/getByCategorie. Осталось только понять, что такое SERVER_API_URL и как именно к нему обращаться.

48955 ~ 48974:
var CDN_URL_PROJECT = '/projects/arizona-rp';
var CDN_CHANNEL_TYPES = {
  CDN_CHANNEL_RESOURCES: 0,
  CDN_CHANNEL_SOUNDS: 1,
  CDN_CHANNEL_SERVER_API: 2
};
var CDN_CONFIG = _defineProperty(_defineProperty(_defineProperty({}, CDN_CHANNEL_TYPES.CDN_CHANNEL_RESOURCES, {
  0: 'https://cdn.azresources.cloud',
  1: 'https://reserve-cdn.azresources.cloud'
}), CDN_CHANNEL_TYPES.CDN_CHANNEL_SOUNDS, {
  0: 'https://cdn.azsounds.cloud',
  1: 'https://reserve-cdn.azsounds.cloud'
}), CDN_CHANNEL_TYPES.CDN_CHANNEL_SERVER_API, {
  0: 'https://server-api.arizona.games',
  1: 'https://reserve-server-api.arizona.games'
});
var CDN_URLS = [CDN_CONFIG[CDN_CHANNEL_TYPES.CDN_CHANNEL_RESOURCES][0], CDN_CONFIG[CDN_CHANNEL_TYPES.CDN_CHANNEL_SOUNDS][0], CDN_CONFIG[CDN_CHANNEL_TYPES.CDN_CHANNEL_SERVER_API][0]];
var CDN_URL = CDN_URLS[CDN_CHANNEL_TYPES.CDN_CHANNEL_RESOURCES] + CDN_URL_PROJECT;
var CDN_SOUNDS_URL = CDN_URLS[CDN_CHANNEL_TYPES.CDN_CHANNEL_SOUNDS];
var SERVER_API_URL = CDN_URLS[CDN_CHANNEL_TYPES.CDN_CHANNEL_SERVER_API];

SERVER_API_URL может принимать два значения - https://server-api.arizona.games и https://reserve-server-api.arizona.games. Итого у нас получается запрос на https://server-api.arizona.games/client/azpotify/v3/az-spotify/getByCategorie. Если постучаться туда просто так - получишь ошибку "Неправильные параметры запроса". Какие же параметры правильные?

1774362935000.png


125162 ~ 125212:
    const updateTracklist = async (pageIndex, genre) => {
        let startIndex = (0,lodash.isEmpty)($viewPlaylist)
        ? 0
        : $viewPlaylist[$viewPlaylist.length - 1].index + 1;

        lib_axios.get(GetUrlAPI(constants_API_URL.GetByGenre), {
            params: {
                type: genre,
                perPage: azpotify_constants_PAGE_SIZE,
                page: pageIndex
            }
        }).then(response => {
            if ($selectedGenre == constants_Genres.Fm) {
                $radioTracks.forEach(radio => {
                    $viewPlaylist.push({
                        id: radio.id,
                        songName: radio.song_name,
                        artistName: radio.artist_name,
                        duration: radio.duration,
                        index: radio.index,
                        like: $favorites.includes(radio.id)
                    });

                    startIndex += 1;
                });
            }

            response.data.data.map((item, i) => {
                utils_set_store_value(
                    viewPlaylist,
                    $viewPlaylist = [
                        ...$viewPlaylist,
                        {
                            id: item.id,
                            songName: item.song_name,
                            artistName: item.artist_name,
                            duration: item.duration,
                            index: i + startIndex,
                            like: $favorites.includes(item.id)
                        }
                    ],
                    $viewPlaylist
                );

                $$invalidate(0, loading = false);
            });
        }).catch(err => {
            $$invalidate(1, errorMessage = 'Произошла ошибка, попробуйте ещё раз');
            $$invalidate(0, loading = false);
        });
    };

Клиент отправляет запрос с тремя параметрами: type (которому передаётся один из известных жанров, см. начало поста), perPage (он захардкожен на 20 в дефолтном клиенте, но в принципе его можно менять - это кол-во песен, которые загружаются за раз) и pageIndex (номер страницы начиная с 1).

Попробуем обратиться с параметрами: https://server-api.arizona.games/client/azpotify/v3/az-spotify/getByCategorie?type=nfs&perPage=15&page=1

1774363246730.png

Получим JSON, в котором каждая песня представлена как объект с четырьмя параметрами - её ID (они тебе уже известны), названием, исполнителем и длительностью в секундах.

По аналогии можно выяснить запрос для получения данных о песне по её ID (он используется "Избранным"):
1774363448138.png


и для поиска по названию:
1774363509574.png


Очень много интересных вещей о клиенте Аризоны можно узнать из файла frontend.zip/svelte_js/main.bundle.js - если потратить время на его чтение ;)
 
  • Влюблен
Реакции: tygodym

nnplayer

Известный
Автор темы
47
7
там весело пиздец:

Начнём со списка жанров, который захардкожен в frontend:
Жанры - строки 125301~125320:
var constants_Genres = {
  Top: 'top',
  Pop: 'pop',
  Indie: 'indie',
  Rnb: 'rnb',
  Electro: 'electronic',
  Classic: 'classic',
  Phonk: 'phonk',
  Rock: 'rock',
  Jazz: 'jazz',
  Chanson: 'chanson',
  Rap: 'rap',
  Country: 'country',
  Delorenzy: 'delorenzy',
  Nfs: 'nfs',
  Fm: 'radio',
  Favorites: 'favorites'
};
var GENRES_TO_VIEW = [constants_Genres.Top, constants_Genres.Pop, constants_Genres.Indie, constants_Genres.Rnb, constants_Genres.Electro, constants_Genres.Classic, constants_Genres.Phonk, constants_Genres.Rock, constants_Genres.Jazz, constants_Genres.Chanson, constants_Genres.Rap, constants_Genres.Delorenzy, constants_Genres.Nfs, constants_Genres.Fm];
var azpotify_constants_MAP_GENRE_TO_ICON = (constants_MAP_GENRE_TO_ICON = {}, azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(constants_MAP_GENRE_TO_ICON, constants_Genres.Top, 'lightning'), constants_Genres.Pop, 'microphone'), constants_Genres.Indie, 'ukulele'), constants_Genres.Rnb, 'cloud-melody'), constants_Genres.Electro, 'disk'), constants_Genres.Classic, 'harp'), constants_Genres.Phonk, 'phonk'), constants_Genres.Rock, 'rock'), constants_Genres.Jazz, 'trumpet'), constants_Genres.Chanson, 'glock'), azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(constants_MAP_GENRE_TO_ICON, constants_Genres.Rap, 'rip'), constants_Genres.Country, 'cowboy'), constants_Genres.Delorenzy, 'delorenzy'), constants_Genres.Nfs, 'race-flag'), constants_Genres.Fm, 'fm'), constants_Genres.Favorites, 'azpotify-like-filled'));
var azpotify_constants_MAP_GENRE_TO_NAME = (constants_MAP_GENRE_TO_NAME = {}, azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(constants_MAP_GENRE_TO_NAME, constants_Genres.Top, 'Топ 100'), constants_Genres.Pop, 'Поп'), constants_Genres.Indie, 'Инди'), constants_Genres.Rnb, 'RnB'), constants_Genres.Punk, 'Панк'), constants_Genres.Electro, 'Электроника'), constants_Genres.Classic, 'Классическая'), constants_Genres.Phonk, 'Phonk'), constants_Genres.Rock, 'Рок'), constants_Genres.Jazz, 'Джаз/Кантри'), azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(azpotify_constants_defineProperty(constants_MAP_GENRE_TO_NAME, constants_Genres.Chanson, 'Шансон'), constants_Genres.Rap, 'Реп и хип-хоп'), constants_Genres.Country, 'Кантри'), constants_Genres.Nfs, 'NFS'), constants_Genres.Fm, 'Радио'), constants_Genres.Delorenzy, 'Delorenzy'), constants_Genres.Favorites, 'Избранное'));
Тебя интересует в первую очередь constants_Genres - это словарь строк, каждая из которых является параметром HTTP-запроса.
Дальше: endpoint, к которому обращается сам клиент, чтобы получать треки по этим жанрам:
125330 ~ 125334:
var constants_API_URL = {
  GetByGenre: '/client/azpotify/v3/az-spotify/getByCategorie',
  GetByName: '/client/azpotify/v1/az-spotify-v2/search',
  GetByIDs: '/client/azpotify/v1/az-spotify-v2/getFavorites'
};
var GetUrlAPI = function GetUrlAPI(route) {
  return "".concat(SERVER_API_URL).concat(route);
};

При получении списка треков по жанру мы обращаемся к ${SERVER_API_URL}/client/azpotify/v3/az-spotify/getByCategorie. Осталось только понять, что такое SERVER_API_URL и как именно к нему обращаться.

48955 ~ 48974:
var CDN_URL_PROJECT = '/projects/arizona-rp';
var CDN_CHANNEL_TYPES = {
  CDN_CHANNEL_RESOURCES: 0,
  CDN_CHANNEL_SOUNDS: 1,
  CDN_CHANNEL_SERVER_API: 2
};
var CDN_CONFIG = _defineProperty(_defineProperty(_defineProperty({}, CDN_CHANNEL_TYPES.CDN_CHANNEL_RESOURCES, {
  0: 'https://cdn.azresources.cloud',
  1: 'https://reserve-cdn.azresources.cloud'
}), CDN_CHANNEL_TYPES.CDN_CHANNEL_SOUNDS, {
  0: 'https://cdn.azsounds.cloud',
  1: 'https://reserve-cdn.azsounds.cloud'
}), CDN_CHANNEL_TYPES.CDN_CHANNEL_SERVER_API, {
  0: 'https://server-api.arizona.games',
  1: 'https://reserve-server-api.arizona.games'
});
var CDN_URLS = [CDN_CONFIG[CDN_CHANNEL_TYPES.CDN_CHANNEL_RESOURCES][0], CDN_CONFIG[CDN_CHANNEL_TYPES.CDN_CHANNEL_SOUNDS][0], CDN_CONFIG[CDN_CHANNEL_TYPES.CDN_CHANNEL_SERVER_API][0]];
var CDN_URL = CDN_URLS[CDN_CHANNEL_TYPES.CDN_CHANNEL_RESOURCES] + CDN_URL_PROJECT;
var CDN_SOUNDS_URL = CDN_URLS[CDN_CHANNEL_TYPES.CDN_CHANNEL_SOUNDS];
var SERVER_API_URL = CDN_URLS[CDN_CHANNEL_TYPES.CDN_CHANNEL_SERVER_API];

SERVER_API_URL может принимать два значения - https://server-api.arizona.games и https://reserve-server-api.arizona.games. Итого у нас получается запрос на https://server-api.arizona.games/client/azpotify/v3/az-spotify/getByCategorie. Если постучаться туда просто так - получишь ошибку "Неправильные параметры запроса". Какие же параметры правильные?

Посмотреть вложение 289546

125162 ~ 125212:
    const updateTracklist = async (pageIndex, genre) => {
        let startIndex = (0,lodash.isEmpty)($viewPlaylist)
        ? 0
        : $viewPlaylist[$viewPlaylist.length - 1].index + 1;

        lib_axios.get(GetUrlAPI(constants_API_URL.GetByGenre), {
            params: {
                type: genre,
                perPage: azpotify_constants_PAGE_SIZE,
                page: pageIndex
            }
        }).then(response => {
            if ($selectedGenre == constants_Genres.Fm) {
                $radioTracks.forEach(radio => {
                    $viewPlaylist.push({
                        id: radio.id,
                        songName: radio.song_name,
                        artistName: radio.artist_name,
                        duration: radio.duration,
                        index: radio.index,
                        like: $favorites.includes(radio.id)
                    });

                    startIndex += 1;
                });
            }

            response.data.data.map((item, i) => {
                utils_set_store_value(
                    viewPlaylist,
                    $viewPlaylist = [
                        ...$viewPlaylist,
                        {
                            id: item.id,
                            songName: item.song_name,
                            artistName: item.artist_name,
                            duration: item.duration,
                            index: i + startIndex,
                            like: $favorites.includes(item.id)
                        }
                    ],
                    $viewPlaylist
                );

                $$invalidate(0, loading = false);
            });
        }).catch(err => {
            $$invalidate(1, errorMessage = 'Произошла ошибка, попробуйте ещё раз');
            $$invalidate(0, loading = false);
        });
    };

Клиент отправляет запрос с тремя параметрами: type (которому передаётся один из известных жанров, см. начало поста), perPage (он захардкожен на 20 в дефолтном клиенте, но в принципе его можно менять - это кол-во песен, которые загружаются за раз) и pageIndex (номер страницы начиная с 1).

Попробуем обратиться с параметрами: https://server-api.arizona.games/client/azpotify/v3/az-spotify/getByCategorie?type=nfs&perPage=15&page=1

Посмотреть вложение 289548
Получим JSON, в котором каждая песня представлена как объект с четырьмя параметрами - её ID (они тебе уже известны), названием, исполнителем и длительностью в секундах.

По аналогии можно выяснить запрос для получения данных о песне по её ID (он используется "Избранным"):
Посмотреть вложение 289549

и для поиска по названию:
Посмотреть вложение 289550

Очень много интересных вещей о клиенте Аризоны можно узнать из файла frontend.zip/svelte_js/main.bundle.js - если потратить время на его чтение ;)
Как тебе не надоело это расписывать я удивляюсь. Надеюсь я смогу в этом разобраться спс
 

БеzликиЙ

Эксперт в области Аризона РПГ
Проверенный
1,996
1,184
Как тебе не надоело это расписывать я удивляюсь. Надеюсь я смогу в этом разобраться спс
да я просто сам рано или поздно это реализовывать буду, как часть arizona-mimgui, на будущее себе можно и сохранить :D