Closed Chesshur closed 3 years ago
Shouldn't be. Can you view it on pandora.com? Additionally, sometimes when you "create" a station on pandora.com it doesn't register as an actual station on your account until you like or dislike something.
Yes, I can see all my stations on Pandora.com and they all have several likes already. I'm using the Chrome version of Anesidora btw if that helps.. I have checked it both on Opera and Chrome browsers and they both have stations missing so I know it's not a problem with the browsers. I have also tried running it with all other extensions disabled and still wouldn't show all of my stations. Also I tested the Firefox version and it doesn't show all of my stations either.
Alright, then. How many stations do you have? I'll read the API docs again to see if there's some sort of pagination inbuilt.
So the JSON API (which we use) doesn't list any pagination details: https://6xq.net/pandora-apidoc/json/stations/
The REST API does: https://6xq.net/pandora-apidoc/rest/stations/
It doesn't seem like there is anything within libpiano for pagination either... https://github.com/PromyLOPh/pianobar/blob/b14c9d6b907ad147d02e9de536e4d396e47af03e/src/libpiano/response.c#L199
On Tue, Sep 7, 2021, 9:39 PM hucario @.***> wrote:
Alright, then. How many stations do you have? I'll read the API docs again to see if there's some sort of pagination inbuilt.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pvrs12/Anesidora/issues/90#issuecomment-914791710, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABVCK4OG2JHAFGLKBCP3HBTUA25FXANCNFSM5DPUKTIA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
I have 122 stations and only 95 of them are listed in Anisedora.
Alright. Debugging time, I suppose. If you could, please follow these steps:
background.htm
under "Inspect Views"Paste this into the console input and press "enter":
async function getStationList() {
console.log('Getting station list...');
let request = JSON.stringify({
"userAuthToken": userAuthToken,
"syncTime": getSyncTime(syncTime),
includeStationArtUrl: true
});
let response = await sendRequest(false, true,"user.getStationList", request);
console.log('Got station list, parsing...');
stationList = response.result.stations;
console.log('Amount of stations received: ' + response.result.stations.length);
stationList.forEach(e => {
stationImgs[e.stationToken] = e.artUrl;
})
localStorage.stationImgs = JSON.stringify(stationImgs);
if (localStorage.userStation === undefined) {
response.result.stations.forEach(function (station) {
if (station.isQuickMix) {
localStorage.userStation = station.stationId;
}
});
}
return stationList;
}
getStationList();
Thanks for the instructions. I tried them both on Opera and Chrome. They both said "undefined" after I pasted the first bit of code intro trhe console. This is what I got on both consoles after typing in the get station list command.
VM90:1 Uncaught ReferenceError: getstationlist is not defined
at
I also noticed Anesidora has errors on both Opera and Chrome. This is what I got for errors:
"use strict" /global partnerLogin, getPlaylist, currentPlaylist, platform_specific, get_browser, is_android/ /exported setCallbacks, play, downloadSong, nextSongStation, mp3Player/
let mp3Player = document.getElementById('mp3Player');
get_browser().webRequest.onBeforeSendHeaders.addListener( function(details) { const h = details.requestHeaders; for (let header of h) { if (header.name.toLowerCase() === "user-agent") { header.value = "libcurl"; } } return {requestHeaders: h}; }, { urls: [ "http://*.pandora.com/services/json/", "https://.pandora.com/services/json/*", ] }, ['blocking', 'requestHeaders'] );
var callbacks = { updatePlayer: [], drawPlayer: [], downloadSong: [] }; var currentSong; var comingSong; var prevSongs = []; var stationImgs = (localStorage.stationImgs && JSON.parse(localStorage.stationImgs)) || {
};
function setCallbacks(updatePlayer,drawPlayer,downloadSong){ callbacks.updatePlayer.push(updatePlayer); callbacks.drawPlayer.push(drawPlayer); callbacks.downloadSong.push(downloadSong); }
async function play(stationToken) { if (stationToken !== localStorage.lastStation) { currentSong = undefined; await getPlaylist(stationToken); //adding this so album covers get on the right location let prev_station = localStorage.lastStation; localStorage.lastStation = stationToken; await nextSong(1, prev_station); } else { if (currentSong === undefined) { await getPlaylist(localStorage.lastStation); } if (mp3Player.currentTime > 0) { mp3Player.play(); } else { await nextSong(); } } }
async function nextSongStation(station) { //adding this so album covers get on the right location let prev_station = localStorage.lastStation; localStorage.lastStation = station; await getPlaylist(localStorage.lastStation); comingSong = undefined; //adding this so album covers get on the right location nextSong(1, prev_station); }
async function nextSong(depth=1, prev_station=undefined) { if (depth > 4){ return; } if (!prev_station) { //if the "prev_station" does not have a definition //then we didn't swap, use the existing one prev_station = localStorage.lastStation; }
/* I (hucario) put this over here so that history and station art works for every song change. */
if (currentSong) {
stationImgs[prev_station] = (currentSong.albumArtUrl || stationImgs[prev_station]) || undefined;
localStorage.stationImgs = JSON.stringify(stationImgs);
if (currentSong != prevSongs[prevSongs.length-1]) {
prevSongs.push(currentSong);
while(prevSongs.length > localStorage.historyNum){
prevSongs.shift();
}
}
}
if (!currentPlaylist || currentPlaylist.length === 0) {
await getPlaylist(localStorage.lastStation);
}
if (comingSong === undefined && currentPlaylist.length > 0) {
comingSong = currentPlaylist.shift();
}
currentSong = comingSong;
//in case the most recent shift emptied the playlist
if (currentPlaylist.length === 0) {
await getPlaylist(localStorage.lastStation);
}
comingSong = currentPlaylist.shift();
let song_url;
if (currentSong.additionalAudioUrl != null) {
song_url = currentSong.additionalAudioUrl;
} else {
song_url = currentSong.audioUrlMap.highQuality.audioUrl;
}
mp3Player.setAttribute("src", song_url);
mp3Player.play();
var xhr = new XMLHttpRequest();
xhr.open("HEAD", song_url);
xhr.onerror = function () {
nextSong(depth + 1);
};
xhr.onload = function() {
if (xhr.status >= 300){
//purge the current list, then run this function again
nextSong(depth + 1);
}
if (localStorage.notifications === "true") {
var options = {
type: "list",
title: "Now playing:\r\n" + currentSong.artistName + " - " + currentSong.songName,
message: "by " + currentSong.artistName,
eventTime: 5000,
items: [
{ title: "", message: "Coming next: " },
{ title: "", message: comingSong.artistName + " - " + comingSong.songName }
]
};
var xhr2 = new XMLHttpRequest();
xhr2.open("GET", currentSong.albumArtUrl);
xhr2.responseType = "blob";
xhr2.onload = function(){
var blob = this.response;
options.iconUrl = window.URL.createObjectURL(blob);
};
xhr2.send(null);
}
callbacks.updatePlayer.forEach((e) => {
try {
e();
} catch(b) {
callbacks.updatePlayer.splice(callbacks.updatePlayer.indexOf(e), 1);
}
});
};
xhr.send();
}
function setup_commands() { if (!is_android()) { get_browser().commands.onCommand.addListener(function(command) { if (command === "pause_play") { if (!mp3Player.paused) { mp3Player.pause(); } else { play(localStorage.lastStation); } } else if(command === "skip_song") { nextSong(); } }); } }
function setup_mediasession() { if (!('mediaSession' in navigator)) { return; }
navigator.mediaSession.setActionHandler("play", async function() {
if(mp3Player.paused) {
play(localStorage.lastStation);
}
});
navigator.mediaSession.setActionHandler("pause", async function() {
if(!mp3Player.paused) {
mp3Player.pause();
}
});
navigator.mediaSession.setActionHandler("nexttrack", async function() {
nextSong();
});
navigator.mediaSession.setActionHandler("seekto", function(details) {
mp3Player.currentTime = details.seekTime;
});
}
function update_mediasession() { if (!('mediaSession' in navigator)) { return; }
// https://github.com/snaphat/pandora_media_session/blob/main/pandora_media_session.user.js#L45
// Populate metadata
var metadata = navigator.mediaSession.metadata;
if (!metadata || (
metadata.title != currentSong.songName ||
metadata.artist != currentSong.artistName ||
metadata.artwork[0].src != currentSong.albumArtUrl)
) {
navigator.mediaSession.metadata = new MediaMetadata({
title: currentSong.songName,
artist: currentSong.artistName,
artwork: [{ src: currentSong.albumArtUrl, sizes: '500x500', type: 'image/jpeg' }]
});
}
if (mp3Player.paused) {
navigator.mediaSession.playbackState = "paused";
} else {
navigator.mediaSession.playbackState = "playing";
if (mp3Player.duration) {
try {
navigator.mediaSession.setPositionState({
duration: mp3Player.duration,
position: mp3Player.currentTime,
playbackRate: 1
});
} catch (e) {
// duration is probably NaN
}
}
}
}
document.addEventListener('DOMContentLoaded', function () { mp3Player = document.getElementById('mp3Player');
if (localStorage.volume) {
mp3Player.volume = localStorage.volume;
} else {
mp3Player.volume = 0.1;
}
platform_specific(get_browser());
setup_commands();
setup_mediasession();
mp3Player = document.getElementById('mp3Player');
mp3Player.addEventListener("play", function () {
try {
//check if the window exists
document.getElementById('mp3Player').yep = 'thisexists'
callbacks.updatePlayer.forEach((e) => {
try {
e();
} catch(b) {
callbacks.updatePlayer.splice(callbacks.updatePlayer.indexOf(e), 1);
}
});
currentSong.startTime = Math.round(new Date().getTime() / 1000);
update_mediasession();
} catch (e) {
//if it doesn"t exist, don"t draw here
return;
}
});
mp3Player.addEventListener("pause", function () {
update_mediasession();
});
mp3Player.addEventListener("ended", function () {
nextSong();
update_mediasession();
});
mp3Player.addEventListener("timeupdate", function () {
update_mediasession();
try {
//check if the window exists
document.getElementById('mp3Player').yep = 'thisexists'
callbacks.drawPlayer.forEach((e) => {
try {
e();
} catch(b) {
callbacks.drawPlayer.splice(callbacks.drawPlayer.indexOf(e), 1);
}
});
} catch(e){
//if it doesn"t, don"t draw here
return;
}
});
mp3Player.addEventListener("error", function () {
});
});
I don't know if that has anything to do with the station list, but I thought I should post the errors here just in case.
It's case sensitive- just copy and paste it in.
Tried pasting the get station commmand and this is what I got:
Promise {
So... the problem isn't on the extension's side. Pandora is only sending us 95 stations, so we can't really do anything.
I thought as such. Thanks for your help anyway.
Not all of my stations are listed. Hittling refresh or logging out and back in does nothing. I even tried uninstalling and reinstalling with no luck. Is there a limit as to how many stations Anesidora can display?