support short link

This commit is contained in:
Sayem Chowdhury 2021-05-19 01:05:09 +06:00
parent 403fd527fd
commit 76e2181010

View File

@ -8,6 +8,7 @@ import {
getTrackInfo, getTrackInfo,
} from '../'; } from '../';
import spotifyUri from 'spotify-uri'; import spotifyUri from 'spotify-uri';
import axios from 'axios';
import * as spotify from './spotify'; import * as spotify from './spotify';
import * as tidal from './tidal'; import * as tidal from './tidal';
import * as youtube from './youtube'; import * as youtube from './youtube';
@ -50,6 +51,10 @@ export const getUrlParts = async (url: string, setToken = false): Promise<urlPar
switch (site[0]) { switch (site[0]) {
case 'deezer': case 'deezer':
if (url.includes('page.link')) {
const {request} = await axios.head(url);
url = request.res.responseUrl;
}
const deezerUrlParts = url.split(/\/(\w+)\/(\d+)/); const deezerUrlParts = url.split(/\/(\w+)\/(\d+)/);
return {type: deezerUrlParts[1] as any, id: deezerUrlParts[2]}; return {type: deezerUrlParts[1] as any, id: deezerUrlParts[2]};