maweki / twitchlive-extension

TwitchLive-Panel Gnome Shell Extension displaying your favorite streamers
GNU General Public License v3.0
38 stars 8 forks source link

Using the display name in urls doesn't always work #65

Closed Master-Miner closed 4 years ago

Master-Miner commented 4 years ago

I don't see a streamer icon in the top bar or drop down menu of the Extension for streamers like lruhon5 (display name: 엘라뀨). Also if I click the menu item ( with "xdg-open http://twitch.tv/%streamer%" command in the settings) , it tries to open twitch.tv/엘라뀨 which doesn't work because the url uses the name I entered in the settings. In the settings the icon is showing up so it looks like you already have a function that loads the icons with the correct url. I currently use the master branch of this extension on Gnome 3.34 so it's not a version issue. It looks like a similar issue came up back in 2016 in Issue #37.

maweki commented 4 years ago

Yeah, it's the same as #37. I explained the changes that need to be done in #63 I sadly currently don't have the time to do it. I am hopeful for a PR.

Master-Miner commented 4 years ago

I manually entered the correct logins of the users because I don't have a twitch account. So I essentially bypass the whole follow function. But even when the list contains the actual logins, line 243 of extension.js uses the user_name of the twitch user streaming instead of that login. So I think you could fix it by either somehow remembering what login belongs to what stream the streams function (extensions.js line 231) returns like a map in the settings (id->login) or pulling them like I did from the stream.user_id (But make it actually work. ;))

I copy-adjusted the "function _users(session, userLogins)" (Api.js line 56) to "function usersid(session, userid) { return new Promise((resolve, reject) => { let url = api_base + 'users ?id=' + userid.join('&id='); load_json_async(session, url, (data) => { if (!data.error) { resolve(data.data); } else { reject(data); } }); }); }"

and used it in extension.js line 234 with: Api.usersid(this._httpSession, [stream.user_id]).then((logins) => { and changed the line 243 to: item.connect("activate", () => this._execCmd(logins[0].login));

my usersid function should work or at least the address worked when I tried it with curl and returned the "login"-field.

But the changed extension didn't show any active streams anymore, so I think I messed up using the function in extension.js. I haven't had any previous javascript experience and also didn't understand the whole promise building/using thing, but I hope this information helps whoever will fix it.

maweki commented 4 years ago

I think I fixed this now. Can you try master? We now work completely with login names, so you might want to reimport the streams from your account.

maweki commented 4 years ago

This is fixed and works now. :)