Skip to content
This repository has been archived by the owner on Feb 4, 2021. It is now read-only.

Commit

Permalink
Also give the users multiple image sizes for twitch
Browse files Browse the repository at this point in the history
  • Loading branch information
freaktechnik committed Apr 29, 2016
1 parent f84effb commit 23f5d67
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/providers/douyutv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @author Martin Giger
* @license MPL-2.0
* @module providers/douyutv
* @todo support adding by url slug name
*/

"use strict";
Expand Down
6 changes: 3 additions & 3 deletions lib/providers/twitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let idOfChannel = new Map();

const SIZES = [ '50', '70', '150', '300' ];
const urlForSize = (imgURL, size) => imgURL.replace("300x300", size+"x"+size);
const getImageObj = (imgURL) => {
const getImageObj = (imgURL = defaultAvatar) => {
let ret = {};
SIZES.forEach((s) => ret[s] = urlForSize(imgURL, s));
return ret;
Expand Down Expand Up @@ -89,7 +89,7 @@ const Twitch = newClass({

let user = new User(data.json.name, this._type);
user.uname = data.json.display_name;
user.image = { 300: data.json.logo?data.json.logo:defaultAvatar };
user.image = getImageObj(data.json.logo?data.json.logo:defaultAvatar);
user.favorites = channels.map((channel) => channel.login);

return [ user, channels ];
Expand Down Expand Up @@ -117,7 +117,7 @@ const Twitch = newClass({
if(data.json && !data.json.error) {
var user = users.find(user => user.login == data.json.name);
user.uname = data.json.display_name;
user.image = { 300: data.json.logo?data.json.logo:defaultAvatar };
user.image = getImageObj(data.json.logo?data.json.logo:defaultAvatar);

new PaginationHelper({
url: baseURL+'/users/'+user.login+'/follows/channels?limit='+itemsPerPage+'&offset=',
Expand Down

0 comments on commit 23f5d67

Please sign in to comment.