use-listen-along
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -63,3 +63,3 @@ 'use strict'; | ||
if (r.track && currently && r.track !== currently && r.track !== track && r.np && !disconnect || r.track && position && !disconnect && (r.end - r.start - dayjs(r.end).diff(dayjs(), 'millisecond')) / 1000 - 15 > position / 1000 || r.track && position && !disconnect && (r.end - r.start - dayjs(r.end).diff(dayjs(), 'millisecond')) / 1000 + 15 < position / 1000) { | ||
if (r.track && currently && r.track !== currently && r.track !== track && r.np && !disconnect || r.track && r.np && currently && r.track == currently && r.track == track && position && !disconnect && (r.end - r.start - dayjs(r.end).diff(dayjs(), 'millisecond')) / 1000 - 15 > position / 1000 || r.track && r.np && currently && r.track == currently && r.track == track && position && !disconnect && (r.end - r.start - dayjs(r.end).diff(dayjs(), 'millisecond')) / 1000 + 15 < position / 1000) { | ||
fetch('https://api.spotify.com/v1/me/player/play', { | ||
@@ -66,0 +66,0 @@ method: 'PUT', |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("dayjs"))&&"object"==typeof t&&"default"in t?t.default:t;exports.useListenAlong=function(t,n,r){var s,a,i,o=!1,l=null,u=function(t){var e,n,r,s,a,i,o,l,u,c;return{error:{status:!t.success,message:null==t||null==(e=t.error)?void 0:e.message},np:null==(n=t.data)?void 0:n.listening_to_spotify,track:null==(r=t.data)||null==(s=r.spotify)?void 0:s.track_id,end:null==t||null==(a=t.data)||null==(i=a.spotify)||null==(o=i.timestamps)?void 0:o.end,start:null==t||null==(l=t.data)||null==(u=l.spotify)||null==(c=u.timestamps)?void 0:c.start}},c=function(t){if(t.error.status)throw new Error(JSON.stringify(t.error));fetch("https://api.spotify.com/v1/me/player/currently-playing?market=from_token",{method:"GET",headers:{Authorization:"Bearer "+n}}).then((function(t){return t.json()})).then((function(t){var e;a=null==t||null==(e=t.item)?void 0:e.id,i=null==t?void 0:t.progress_ms})),(t.track&&a&&t.track!==a&&t.track!==s&&t.np&&!r||t.track&&i&&!r&&(t.end-t.start-e(t.end).diff(e(),"millisecond"))/1e3-15>i/1e3||t.track&&i&&!r&&(t.end-t.start-e(t.end).diff(e(),"millisecond"))/1e3+15<i/1e3)&&(fetch("https://api.spotify.com/v1/me/player/play",{method:"PUT",headers:{Authorization:"Bearer "+n,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uris:["spotify:track:"+t.track],position_ms:t.end-t.start-e(t.end).diff(e(),"millisecond")})}).then((function(t){o=204==t.status,l=204!==t.status?403==t.status?"User must have a premium account.":t.statusText:null})).catch((function(t){if(t.status)throw new Error(t)})),s=t.track)};return setInterval((function(){r||fetch("https://api.lanyard.rest/v1/users/"+t).then((function(t){return t.json()})).then(u).then(c)}),1500),{connected:o,error:l}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=(t=require("dayjs"))&&"object"==typeof t&&"default"in t?t.default:t;exports.useListenAlong=function(t,n,r){var s,a,i,o=!1,l=null,u=function(t){var e,n,r,s,a,i,o,l,u,c;return{error:{status:!t.success,message:null==t||null==(e=t.error)?void 0:e.message},np:null==(n=t.data)?void 0:n.listening_to_spotify,track:null==(r=t.data)||null==(s=r.spotify)?void 0:s.track_id,end:null==t||null==(a=t.data)||null==(i=a.spotify)||null==(o=i.timestamps)?void 0:o.end,start:null==t||null==(l=t.data)||null==(u=l.spotify)||null==(c=u.timestamps)?void 0:c.start}},c=function(t){if(t.error.status)throw new Error(JSON.stringify(t.error));fetch("https://api.spotify.com/v1/me/player/currently-playing?market=from_token",{method:"GET",headers:{Authorization:"Bearer "+n}}).then((function(t){return t.json()})).then((function(t){var e;a=null==t||null==(e=t.item)?void 0:e.id,i=null==t?void 0:t.progress_ms})),(t.track&&a&&t.track!==a&&t.track!==s&&t.np&&!r||t.track&&t.np&&a&&t.track==a&&t.track==s&&i&&!r&&(t.end-t.start-e(t.end).diff(e(),"millisecond"))/1e3-15>i/1e3||t.track&&t.np&&a&&t.track==a&&t.track==s&&i&&!r&&(t.end-t.start-e(t.end).diff(e(),"millisecond"))/1e3+15<i/1e3)&&(fetch("https://api.spotify.com/v1/me/player/play",{method:"PUT",headers:{Authorization:"Bearer "+n,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({uris:["spotify:track:"+t.track],position_ms:t.end-t.start-e(t.end).diff(e(),"millisecond")})}).then((function(t){o=204==t.status,l=204!==t.status?403==t.status?"User must have a premium account.":t.statusText:null})).catch((function(t){if(t.status)throw new Error(t)})),s=t.track)};return setInterval((function(){r||fetch("https://api.lanyard.rest/v1/users/"+t).then((function(t){return t.json()})).then(u).then(c)}),1500),{connected:o,error:l}}; | ||
//# sourceMappingURL=use-listen-along.cjs.production.min.js.map |
@@ -57,3 +57,3 @@ import dayjs from 'dayjs'; | ||
if (r.track && currently && r.track !== currently && r.track !== track && r.np && !disconnect || r.track && position && !disconnect && (r.end - r.start - dayjs(r.end).diff(dayjs(), 'millisecond')) / 1000 - 15 > position / 1000 || r.track && position && !disconnect && (r.end - r.start - dayjs(r.end).diff(dayjs(), 'millisecond')) / 1000 + 15 < position / 1000) { | ||
if (r.track && currently && r.track !== currently && r.track !== track && r.np && !disconnect || r.track && r.np && currently && r.track == currently && r.track == track && position && !disconnect && (r.end - r.start - dayjs(r.end).diff(dayjs(), 'millisecond')) / 1000 - 15 > position / 1000 || r.track && r.np && currently && r.track == currently && r.track == track && position && !disconnect && (r.end - r.start - dayjs(r.end).diff(dayjs(), 'millisecond')) / 1000 + 15 < position / 1000) { | ||
fetch('https://api.spotify.com/v1/me/player/play', { | ||
@@ -60,0 +60,0 @@ method: 'PUT', |
{ | ||
"name": "use-listen-along", | ||
"description": "A react hook to listen alongside others on spotify.", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.js", |
@@ -75,2 +75,6 @@ import { LanyardResponse } from './types'; | ||
(r.track && | ||
r.np && | ||
currently && | ||
r.track == currently && | ||
r.track == track && | ||
position && | ||
@@ -82,2 +86,6 @@ !disconnect && | ||
(r.track && | ||
r.np && | ||
currently && | ||
r.track == currently && | ||
r.track == track && | ||
position && | ||
@@ -84,0 +92,0 @@ !disconnect && |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41420
469