forked from tastytea/userscripts
Compare commits
13 Commits
Author | SHA1 | Date |
---|---|---|
tastytea | 886a214924 | |
tastytea | 4dfe33bd4c | |
tastytea | ab22e1043b | |
tastytea | edd90c4c9c | |
tastytea | 697eb57ab8 | |
tastytea | 0d63fc0600 | |
tastytea | 09885123b3 | |
tastytea | e9b803c50c | |
tastytea | 6a2eadc05a | |
tastytea | c98448e7c8 | |
tastytea | 9bf6450d47 | |
tastytea | 706a49885f | |
tastytea | 30ae58f42f |
|
@ -2,9 +2,9 @@
|
|||
// @name DLF download button
|
||||
// @description Adds a download button for each audio file on DLF sites.
|
||||
// @description:de Fügt einen download-button für jede audio-datei auf DLF-seiten hinzu.
|
||||
// @version 2021.04.29.1
|
||||
// @version 2022.07.17.1
|
||||
// @author tastytea
|
||||
// @copyright 2019, 2021, tastytea (https://tastytea.de/)
|
||||
// @copyright 2019, 2021, 2022, tastytea (https://tastytea.de/)
|
||||
// @license GPL-3.0-only
|
||||
// @namespace tastytea.de
|
||||
// @homepageURL https://schlomp.space/tastytea/userscripts
|
||||
|
@ -18,7 +18,7 @@
|
|||
// @inject-into content
|
||||
// ==/UserScript==
|
||||
|
||||
function main()
|
||||
function dlf_us_main()
|
||||
{
|
||||
// deutschlandradio.de, deutschlandfunkkultur.de
|
||||
let root = document.getElementsByClassName("player-embed")[0];
|
||||
|
@ -36,6 +36,14 @@ function main()
|
|||
return;
|
||||
}
|
||||
|
||||
// share.deutschlandradio.de
|
||||
root = document.getElementsByClassName("b-btn-player")[1];
|
||||
if (root !== undefined)
|
||||
{
|
||||
add_button(root.getAttribute("data-audioreference"));
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn("Could not find player / download-button element.");
|
||||
}
|
||||
|
||||
|
@ -55,7 +63,7 @@ function add_button(url)
|
|||
}
|
||||
else if (window.location.href.search("deutschlandfunkkultur.de") > 0)
|
||||
{
|
||||
button.setAttribute("class", "drk-articleplay");
|
||||
button.style.fontWeight = "bold";
|
||||
}
|
||||
button.style.textDecoration = "underline";
|
||||
|
||||
|
@ -83,7 +91,15 @@ function add_button(url)
|
|||
return;
|
||||
}
|
||||
|
||||
// share.deutschlandradio.de
|
||||
root = document.getElementsByClassName("b-audio-player-wrapper")[0];
|
||||
if (root !== undefined)
|
||||
{
|
||||
root.parentElement.insertBefore(button, root);
|
||||
return;
|
||||
}
|
||||
|
||||
console.warn("Could not find root element.");
|
||||
}
|
||||
|
||||
main();
|
||||
dlf_us_main();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
// @name Goodreads expand
|
||||
// @description Show the whole description / author information / book details on goodreads.com.
|
||||
// @description:de Zeige die ganze beschreibung / author·inneninformation / buchdetails auf goodreads.com an.
|
||||
// @version 2021.04.24.1
|
||||
// @version 2021.07.20.1
|
||||
// @author tastytea
|
||||
// @copyright 2020, 2021, tastytea (https://tastytea.de/)
|
||||
// @license GPL-3.0-only
|
||||
|
@ -11,8 +11,7 @@
|
|||
// @supportURL https://schlomp.space/tastytea/userscripts/issues
|
||||
// @downloadURL https://schlomp.space/tastytea/userscripts/raw/branch/main/catalogues/goodreads_expand.user.js
|
||||
// @grant none
|
||||
// @match https://www.goodreads.com/book/*
|
||||
// @match https://www.goodreads.com/author/*
|
||||
// @match https://www.goodreads.com/*
|
||||
// @run-at document-end
|
||||
// @inject-into content
|
||||
// ==/UserScript==
|
||||
|
@ -55,3 +54,29 @@
|
|||
document.getElementById("bookDataBoxShow").setAttribute("style", "display: none;");
|
||||
}
|
||||
})();
|
||||
|
||||
// On-hover book descriptions are getting loaded dynamically, so we have to look
|
||||
// for them periodically.
|
||||
function userscript_expand_hover_description()
|
||||
{
|
||||
const descriptions = document.getElementsByClassName("addBookTipDescription");
|
||||
for (const element of descriptions)
|
||||
{
|
||||
if (element == null) // null or undefined.
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const spans = element.getElementsByTagName("span");
|
||||
if (spans.length >= 2)
|
||||
{
|
||||
spans[1].setAttribute("style", "display: block;");
|
||||
spans[0].setAttribute("style", "display: none;");
|
||||
|
||||
const links = element.getElementsByTagName("a");
|
||||
links[links.length - 1].text = "(less)";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(userscript_expand_hover_description, 1000);
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
// ==UserScript==
|
||||
// @name Misskey CW toggle
|
||||
// @description Adds a button to toggle the visibility of all notes with content warnings on note-pages.
|
||||
// @version 2023.1.26.2
|
||||
// @author tastytea
|
||||
// @copyright 2022-2023, tastytea (https://tastytea.de/)
|
||||
// @license GPL-3.0-only
|
||||
// @namespace tastytea.de
|
||||
// @homepageURL https://schlomp.space/tastytea/userscripts
|
||||
// @supportURL https://schlomp.space/tastytea/userscripts/issues
|
||||
// @downloadURL https://schlomp.space/tastytea/userscripts/raw/branch/main/fediverse/misskey_cw_toggle.user.js
|
||||
// @grant none
|
||||
// @match https://*/notes/*
|
||||
// @run-at document-end
|
||||
// @inject-into content
|
||||
// ==/UserScript==
|
||||
|
||||
let interval;
|
||||
let counter = 0;
|
||||
|
||||
function get_root() {
|
||||
const root = document.getElementsByClassName("lxwezrsl note")[0]; // MK 13
|
||||
if (root === undefined) {
|
||||
root = document.getElementsByClassName("_block note")[0]; // MK 12
|
||||
}
|
||||
return root;
|
||||
}
|
||||
|
||||
// Toggle the visibility of each status with CW.
|
||||
function toggle() {
|
||||
const root = get_root()
|
||||
if (root === undefined) {
|
||||
return;
|
||||
}
|
||||
const cw_classes = ["cw", "xpfPt"];
|
||||
for (let classname of cw_classes) {
|
||||
for (let status of root.getElementsByClassName(classname)) {
|
||||
let button = status.getElementsByTagName("button")[0];
|
||||
if (button === undefined) {
|
||||
continue;
|
||||
}
|
||||
button.click();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add a “Toggle all CWs”-button.
|
||||
function add_button() {
|
||||
const root = get_root()
|
||||
if (root === undefined) {
|
||||
console.error("No suitable parent-element found.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const button = document.createElement("button");
|
||||
button.setAttribute("id", "global-cw-toggle");
|
||||
button.setAttribute("class", "_button");
|
||||
button.setAttribute("style", "margin-top: 0.2em; margin-right: 0.5em;");
|
||||
button.appendChild(document.createTextNode("Toggle all CWs"));
|
||||
|
||||
root.insertBefore(button, root.firstChild);
|
||||
|
||||
button.onclick = toggle;
|
||||
}
|
||||
|
||||
function check() {
|
||||
const root = get_root()
|
||||
if (root === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If there is a “Show content” button, add our button, if we didn't do so before.
|
||||
if (root.getElementsByClassName("cw").length > 0
|
||||
&& document.getElementById("global-cw-toggle") === null) {
|
||||
add_button();
|
||||
console.debug("Global CW toggle button added");
|
||||
}
|
||||
}
|
||||
|
||||
interval = setInterval(check, 1000); // Try to add button every second.
|
|
@ -1,9 +1,9 @@
|
|||
// ==UserScript==
|
||||
// @name Pleroma CW toggle
|
||||
// @description Adds a button to toggle the visibility of all statuses with content warnings on status-pages, profile-pages and timelines.
|
||||
// @version 2019.06.25.2
|
||||
// @version 2022.02.19.2
|
||||
// @author tastytea
|
||||
// @copyright 2019, tastytea (https://tastytea.de/)
|
||||
// @copyright 2019, 2022, tastytea (https://tastytea.de/)
|
||||
// @license GPL-3.0-only
|
||||
// @namespace tastytea.de
|
||||
// @homepageURL https://schlomp.space/tastytea/userscripts
|
||||
|
@ -105,13 +105,13 @@ function check()
|
|||
{
|
||||
parent = root[0].parentElement;
|
||||
}
|
||||
// if root element and a status was found, disable interval and add button.
|
||||
if (root.length !== 0
|
||||
&& parent.getElementsByClassName("status-content").length > 0)
|
||||
// if root element and a status was found, add button.
|
||||
if (root.length !== 0)
|
||||
{
|
||||
if (is_static)
|
||||
if (!parent.getElementsByClassName("StatusContent").length > 0
|
||||
&& !parent.getElementsByClassName("status-content").length > 0)
|
||||
{
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
|
||||
for (let element of root)
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
const expect = require('chai').expect;
|
||||
const alltomp3 = require('..');
|
||||
const _ = require('lodash');
|
||||
|
||||
/**
|
||||
* Lyrics uses 5 or 6 different websites,
|
||||
* and the first to answer is the one chosen.
|
||||
* So it is absolutely non determinist, and
|
||||
* these tests are repeated 5 times.
|
||||
* Moreover lyrics varies depending on the website,
|
||||
* and can sometimes be wrong...
|
||||
*/
|
||||
|
||||
describe('findLyrics', () => {
|
||||
|
||||
for (let i = 0; i < 5; i += 1) {
|
||||
it('should find lyrics for Imagine Dragons - On Top of the World', (done) => {
|
||||
alltomp3.findLyrics('On Top of the World', 'Imagine Dragons').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/^if-you-love-somebody-better-tell-them-while-theyre-here/);
|
||||
expect(lyrics).to.match(/(when-you-hit-the-ground-get-up-now-get-up-get-up-now)|(i-can-been-dreaming-of-this-since-a-child-im-on-top-of-the-world)$/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for Pauline Croze - T\'es Beau', (done) => {
|
||||
alltomp3.findLyrics('T\'es beau', 'Pauline Croze').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/tes-beau-parce-que-tes-courageux-de-regarder-dans-le-fond-des-yeux-celui-qui-te-defie-detre-heureux/);
|
||||
expect(lyrics).to.match(/jai-peur-doublier-jai-peur-daccepter-jai-peur-des-vivants-a-present-tes-beau$/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for M - Mama Sam', (done) => {
|
||||
alltomp3.findLyrics('Mama Sam', 'M').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/^quand-je-te-revois-mama-sam-je-retrouve-les-vraies-valeurs/);
|
||||
expect(lyrics).to.match(/non-je-ne-connais-pas-l-afrique-aigrie-est-ma-couleur-de-peau-la-vie-est-une-machine-a-fric-ou-les-affreux-non(t?)-pas-dafro$/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for Coldplay - Viva la Vida', (done) => {
|
||||
alltomp3.findLyrics('Viva la Vida', 'Coldplay').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/^i-used-to-rule-the-world-seas-would-rise-when-i-gave-the-word/);
|
||||
expect(lyrics).to.match(/for-some-reason-i-cant-explain-i-know-saint-peter-wont-call-my-name-never-an-honest-word-but-that-was-when-i-ruled-the-world/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for HYPHEN HYPHEN - Cause I Got A Chance', (done) => {
|
||||
alltomp3.findLyrics('Cause I Got A Chance', 'HYPHEN HYPHEN').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/^tonight-i-dont-wanna-cry-tonight-i-want-you-to-dance-with-me-tonight/);
|
||||
expect(lyrics).to.match(/ive-been-waiting-for-so-long-knew-you-always-thought-about-always-thought-about-me$/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for Calvin Harris - The Rain', (done) => {
|
||||
alltomp3.findLyrics('The Rain', 'Calvin Harris').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/^shes-the-type-of-girl-that-makes-you-feel-better/);
|
||||
expect(lyrics).to.match(/these-are-the-good-times-in-your-life-so-put-on-a-smile-and-itll-be-((alright)|(all-right))/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for Sam Smith - Writing\'s on the Wall', (done) => {
|
||||
alltomp3.findLyrics('Writing\'s on the Wall', 'Sam Smith').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/^ive-been-here-before-but-always-hit-the-floor-ive-spent-a-lifetime-running-and-i-always-get-away/);
|
||||
expect(lyrics).to.match(/where-i-give-it-all-up-for-you-i-have-to-risk-it-all-cause-the-writings-on-the-wall$/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for C2C - Down The Road', (done) => {
|
||||
alltomp3.findLyrics('Down The Road', 'C2C').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/have-no-place-to-go-have-no-place-to-go-darling/);
|
||||
expect(lyrics).to.match(/when-that-train-rolls-up-and-i-come-walking-out/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for Galantis - Runaway (U & I)', (done) => {
|
||||
alltomp3.findLyrics('Runaway (U & I)', 'Galantis').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/think-i-can-fly-think-i-can-fly-when-im-with-u/);
|
||||
expect(lyrics).to.match(/i-know-that-im-rich-enough-for-pride-i-see-a-billion-dollars-in-your-eyes-even-if-were-strangers/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('should find lyrics for Mika - Elle me dit', (done) => {
|
||||
alltomp3.findLyrics('Elle me dit', 'Mika').then((lyrics) => {
|
||||
lyrics = _.kebabCase(lyrics);
|
||||
|
||||
expect(lyrics).to.match(/elle-me-dit-ecris-une-chanson-contente-pas-une-chanson-deprimante-une-chanson-que-tout-l((e-)?)monde-aime/);
|
||||
expect(lyrics).to.match(/pourquoi-tu-gaches-ta-vie-pourquoi-tu-gaches-ta-vie/);
|
||||
expect(lyrics).to.match(/regarde-un-peu-tes-amis-quest-c((e-)?)quils-vont-faire-de-leur-vie/);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
|
@ -1,224 +0,0 @@
|
|||
const expect = require('chai').expect;
|
||||
const alltomp3 = require('..');
|
||||
const _ = require('lodash');
|
||||
|
||||
function testTracks(tracks, artistName) {
|
||||
let queries = [];
|
||||
_.forEach(tracks, t => {
|
||||
t.song.artistName = artistName;
|
||||
let q = alltomp3.findVideoForSong(t.song).then(v => {
|
||||
if (t.videos.indexOf(v[0].url) === -1) {
|
||||
console.log(t.song.title, v);
|
||||
}
|
||||
expect(t.videos).to.include(v[0].url);
|
||||
});
|
||||
queries.push(q);
|
||||
});
|
||||
|
||||
return Promise.all(queries);
|
||||
}
|
||||
|
||||
describe('findVideo', function() {
|
||||
it('should find YouTube videos for Broken Back by Broken Back', function () {
|
||||
this.timeout(20000);
|
||||
let artistName = "Broken Back";
|
||||
let tracks = [
|
||||
{
|
||||
song: {
|
||||
title: "Excuses",
|
||||
duration: 224
|
||||
},
|
||||
videos: ['https://www.youtube.com/watch?v=aBp7s6BpmrM', 'https://www.youtube.com/watch?v=Ogsfvvwu-wU', 'https://www.youtube.com/watch?v=upUWTD6x3dw']
|
||||
},
|
||||
{
|
||||
song: {
|
||||
title: "Halcyon Birds (Radio Edit)",
|
||||
duration: 197
|
||||
},
|
||||
videos: ['https://www.youtube.com/watch?v=xWlXEGIol9E', 'https://www.youtube.com/watch?v=EGSqjTixIyk', 'https://www.youtube.com/watch?v=gzZ43IEJ8S0', 'https://www.youtube.com/watch?v=2Ggu0m0a8WA', 'https://www.youtube.com/watch?v=5eS1WxW4GM4']
|
||||
},
|
||||
{
|
||||
song: {
|
||||
title: "Better Run",
|
||||
duration: 176
|
||||
},
|
||||
videos: ['https://www.youtube.com/watch?v=oEugd8BV_Bs', 'https://www.youtube.com/watch?v=5QP8K42-wA8'],
|
||||
},
|
||||
{
|
||||
song: {
|
||||
title: "Happiest Man on Earth (Radio Edit)",
|
||||
duration: 183
|
||||
},
|
||||
videos: ['https://www.youtube.com/watch?v=j01T8N7wVK0', 'https://www.youtube.com/watch?v=TqpM_0_H6Qc'],
|
||||
},
|
||||
{
|
||||
song: {
|
||||
title: "Got to Go",
|
||||
duration: 218
|
||||
},
|
||||
videos: ['https://www.youtube.com/watch?v=A2iBEZBxT3s', 'https://www.youtube.com/watch?v=MXABmCs5Fkc']
|
||||
},
|
||||
// This last one is currently too hard
|
||||
// {
|
||||
// title: "Young Souls (Album Edit) - Broken Back",
|
||||
// videos: ['https://www.youtube.com/watch?v=LT9kwbunzWc']
|
||||
// }
|
||||
];
|
||||
|
||||
return testTracks(tracks, artistName);
|
||||
});
|
||||
|
||||
it('should find YouTube videos for Night Visions by Imagine Dragons', function () {
|
||||
this.timeout(20000);
|
||||
let artistName = "Imagine Dragons";
|
||||
|
||||
let tracks = [
|
||||
{
|
||||
"song": {
|
||||
"title": "Radioactive",
|
||||
"duration": 186
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=ktvTqknDobU', 'https://www.youtube.com/watch?v=iO_WxYC34eM', 'https://www.youtube.com/watch?v=Thbsg9i2mZ0', 'https://www.youtube.com/watch?v=y_8Mgn30xRU']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Tiptoe",
|
||||
"duration": 194
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=ajjj4pLnjz8', 'https://www.youtube.com/watch?v=UB96k1arlTk', 'https://www.youtube.com/watch?v=211bk6ctXM4', 'https://www.youtube.com/watch?v=zmKv2Aok1Mw']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "It's Time",
|
||||
"duration": 240
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=sENM2wA_FTg', 'https://www.youtube.com/watch?v=IOatp-OCw3E', 'https://www.youtube.com/watch?v=qFqMy0ewYFQ']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Demons",
|
||||
"duration": 177
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=mWRsgZuwf_8', 'https://www.youtube.com/watch?v=GFQYaoiIFh8', 'https://www.youtube.com/watch?v=LqI78S14Wgg', 'https://www.youtube.com/watch?v=lxUXvOUKM_Q']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "On Top Of The World",
|
||||
"duration": 192
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=w5tWYmIOWGk', 'https://www.youtube.com/watch?v=g8PrTzLaLHc', 'https://www.youtube.com/watch?v=Nwvil057g-g', 'https://www.youtube.com/watch?v=e74VMNgARvY']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Amsterdam",
|
||||
"duration": 241
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=TKtPXO5iEnA', 'https://www.youtube.com/watch?v=s6Nc4qEI3k4', 'https://www.youtube.com/watch?v=dboQYGddEC8', 'https://www.youtube.com/watch?v=j-tfNaBcyes']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Hear Me",
|
||||
"duration": 235
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=1Yr683VLxes', 'https://www.youtube.com/watch?v=EkB2eJfF3W8', 'https://www.youtube.com/watch?v=u0Q3r4ywA34']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Every Night",
|
||||
"duration": 217
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=6RVxzeBiBJU', 'https://www.youtube.com/watch?v=kuijhOvKyYg', 'https://www.youtube.com/watch?v=f6CQ3ATP_6Y', 'https://www.youtube.com/watch?v=k4ESylzBW4M']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Bleeding Out",
|
||||
"duration": 223
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=jNFgynmVmx0', 'https://www.youtube.com/watch?v=gJEoxeW7JvQ', 'https://www.youtube.com/watch?v=Hq6kn87NpKw', 'https://www.youtube.com/watch?v=Tyjt1Ff4m7k']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Underdog",
|
||||
"duration": 209
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=JCUV43T7HZ0', 'https://www.youtube.com/watch?v=USeEyhodZqk', 'https://www.youtube.com/watch?v=KoX80w5b8ps', 'https://www.youtube.com/watch?v=m4SBGLtJvPo', 'https://www.youtube.com/watch?v=2RQRoTvXXiw']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Nothing Left To Say / Rocks (Medley)",
|
||||
"duration": 537
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=Bn7eYibzmTs', 'https://www.youtube.com/watch?v=bSBkYqbdOKc', 'https://www.youtube.com/watch?v=B4z7loNm_kw', 'https://www.youtube.com/watch?v=Q6zqH6qKaTU', 'https://www.youtube.com/watch?v=zCqHNBleR6M']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Cha-Ching (Till We Grow Older)",
|
||||
"duration": 249
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=rmqyXQf8jkU', 'https://www.youtube.com/watch?v=vhSvfxtlUQc', 'https://www.youtube.com/watch?v=wO0ohGn-x3E', 'https://www.youtube.com/watch?v=IgC8yZpMRqc', 'https://www.youtube.com/watch?v=zTingWDAAts']
|
||||
},
|
||||
{
|
||||
"song": {
|
||||
"title": "Working Man",
|
||||
"duration": 235
|
||||
},
|
||||
"videos": ['https://www.youtube.com/watch?v=m4SBGLtJvPo', 'https://www.youtube.com/watch?v=2d-GIw-pBMs', 'https://www.youtube.com/watch?v=NARf6QW3KYA', 'https://www.youtube.com/watch?v=31YTMhD4NYs', 'https://www.youtube.com/watch?v=mhXoXYbmCz4', 'https://www.youtube.com/watch?v=2d-GIw-pBMs', 'https://www.youtube.com/watch?v=aW8_7M8e5CQ']
|
||||
}
|
||||
];
|
||||
|
||||
return testTracks(tracks, artistName);
|
||||
});
|
||||
|
||||
// Failed, but the videos it finds are unavailable
|
||||
// Should update testTracks() so it checks if the video is available or not
|
||||
// it('should find YouTube videos for Night Shift (Original Mix) by Overwerk', function () {
|
||||
// this.timeout(10000);
|
||||
//
|
||||
// let artistName = "Overwerk";
|
||||
// let tracks = [
|
||||
// {
|
||||
// song: {
|
||||
// title: "Night Shift (Original Mix)",
|
||||
// duration: 541
|
||||
// },
|
||||
// videos: ['https://www.youtube.com/watch?v=SI2wnEvrepM', 'https://www.youtube.com/watch?v=87bCbQHez9k', 'https://www.youtube.com/watch?v=dtq9NNLa1O8']
|
||||
// },
|
||||
// {
|
||||
// song: {
|
||||
// title: "Last Call (Original Mix)",
|
||||
// duration: 600
|
||||
// },
|
||||
// videos: ['https://www.youtube.com/watch?v=4C9LACMJFT4', 'https://www.youtube.com/watch?v=eQMXBaB0Ehs', 'https://www.youtube.com/watch?v=RzKCHDgQZ9g']
|
||||
// }
|
||||
// ];
|
||||
//
|
||||
// return testTracks(tracks, artistName);
|
||||
// });
|
||||
|
||||
it('should find YouTube videos for single letter artist M', function () {
|
||||
this.timeout(10000);
|
||||
|
||||
// It's a French song
|
||||
alltomp3.regionCode = 'FR';
|
||||
|
||||
let artistName = "M";
|
||||
let tracks = [
|
||||
{
|
||||
song: {
|
||||
title: "Je dis aime",
|
||||
duration: 236
|
||||
},
|
||||
videos: ['https://www.youtube.com/watch?v=6hV-UnrC9tU', 'https://www.youtube.com/watch?v=QYWV67qgHvg', 'https://www.youtube.com/watch?v=ORam68OtcmY']
|
||||
},
|
||||
{
|
||||
song: {
|
||||
title: "Mama Sam",
|
||||
duration: 195
|
||||
},
|
||||
videos: ['https://www.youtube.com/watch?v=avZTCTR6e9k', 'https://www.youtube.com/watch?v=HRez3YiXxJw']
|
||||
}
|
||||
];
|
||||
|
||||
return testTracks(tracks, artistName);
|
||||
});
|
||||
});
|
|
@ -1,40 +0,0 @@
|
|||
const expect = require('chai').expect;
|
||||
const alltomp3 = require('..');
|
||||
const _ = require('lodash');
|
||||
|
||||
describe('guessTrackFromString', function() {
|
||||
it('should guess the right track', function () {
|
||||
this.timeout(20000);
|
||||
let queries = [
|
||||
{
|
||||
q: "Kungs vs Cookin’ on 3 Burners - This Girl",
|
||||
title: "This Girl (Kungs Vs. Cookin' On 3 Burners)",
|
||||
a: "Kungs"
|
||||
},
|
||||
{
|
||||
q: "'City of Stars' (Duet ft. Ryan Gosling, Emma Stone) - La La Land Original Motion Picture Soundtrack",
|
||||
t: "City of Stars",
|
||||
a: "Piano Dreamers"
|
||||
},
|
||||
{
|
||||
q: "Imagine Dragons - On Top Of The World (Official Music Video)",
|
||||
t: "On Top Of The World",
|
||||
a: "Imagine Dragons"
|
||||
},
|
||||
{
|
||||
q: "Mika - Elle Me Dit (clip officiel)",
|
||||
t: "Elle Me Dit",
|
||||
a: "Mika"
|
||||
}
|
||||
];
|
||||
let promises = [];
|
||||
_.forEach(queries, q => {
|
||||
let p = alltomp3.guessTrackFromString(q.q).then(a => {
|
||||
expect(a.title).to.be(q.t);
|
||||
expect(a.artistName).to.be(q.a);
|
||||
});
|
||||
promises.push(p);
|
||||
});
|
||||
return promises;
|
||||
});
|
||||
});
|
2395
paxt002/index.js
2395
paxt002/index.js
File diff suppressed because it is too large
Load Diff
211
paxt002/test.js
211
paxt002/test.js
|
@ -1,211 +0,0 @@
|
|||
const alltomp3 = require('.');
|
||||
const util = require('util');
|
||||
|
||||
// alltomp3.spotifyToken().then(o => console.log(o)).catch(e => console.log(e));
|
||||
|
||||
// alltomp3.getPlaylistTitlesInfos('https://open.spotify.com/user/spotify_france/playlist/1h4ZB3lW7lD5RmfE6DIRRI').then(d => console.log(util.inspect(d, {depth: 2})));
|
||||
|
||||
// alltomp3.getSpotifyTrackInfos('1NOPjzkLIEUM6mwGxCm2mM').then(i => console.log(i));
|
||||
|
||||
// alltomp3.configEyeD3('/Users/ntag/Projets/alltomp3/alltomp3-app/bin/eyeD3/bin/eyeD3', '/Users/ntag/Projets/alltomp3/alltomp3-app/bin/eyeD3/build/lib');
|
||||
// alltomp3.getInfosWithYoutubeDl('https://soundcloud.com/taylorythm/coda', function(infos) {
|
||||
// console.log(infos);
|
||||
// });
|
||||
// alltomp3.getInfosWithYoutubeDl('https://www.youtube.com/watch?v=e74VMNgARvY', function(infos) {
|
||||
// console.log(infos);
|
||||
// });
|
||||
// not working URL https://www.youtube.com/watch?v=yzi-7G2u89g
|
||||
// var dl = alltomp3.findAndDownload("mika elle me dit", "./", () => {}, true);
|
||||
// dl.on("download", function (infos) {
|
||||
// process.stdout.cursorTo(0);
|
||||
// process.stdout.clearLine(1);
|
||||
// process.stdout.write(infos.progress + "%");
|
||||
// });
|
||||
// dl.on("download-end", function () {
|
||||
// console.log("Download end");
|
||||
// });
|
||||
// dl.on("convert", function (infos) {
|
||||
// process.stdout.cursorTo(0);
|
||||
// process.stdout.clearLine(1);
|
||||
// process.stdout.write(infos.progress + "%");
|
||||
// });
|
||||
// dl.on("error", function (e) {
|
||||
// console.log("Error la la", util.inspect(e));
|
||||
// });
|
||||
|
||||
// alltomp3.getInfosWithYoutubeDl('https://www.youtube.com/watch?v=sX9s-bSOYxk').then(console.log);
|
||||
|
||||
// const dl = alltomp3.downloadWithYoutubeDl('https://www.youtube.com/watch?v=sX9s-bSOYxk', 'test.mp3');
|
||||
// dl.on('download-progress', console.log);
|
||||
// dl.once('download-end', console.log);
|
||||
// dl.on('error', console.error);
|
||||
|
||||
// alltomp3.guessTrackFromString('Imagine Dragons - On Top of the World - Lyrics', false, false, true);
|
||||
// alltomp3.guessTrackFromString('C2C - Happy Ft. D.Martin', false, false, true);
|
||||
// alltomp3.guessTrackFromString('David Guetta - Bang My Head (Official Video) feat Sia & Fetty Wap', false, false, true);
|
||||
// alltomp3.guessTrackFromString('David Guetta - Hey Mama (Official Video) ft Nicki Minaj, Bebe Rexha & Afrojack', false, false, true);
|
||||
// alltomp3.retrieveTrackInformations('On Top of the World', 'Imagine Dragons').then(function (infos) {
|
||||
// console.log("Infos: ", infos);
|
||||
// });
|
||||
|
||||
// alltomp3.guessTrackFromFile('./test.mp3').then(function (infos) {
|
||||
// return alltomp3.retrieveTrackInformations(infos.title, infos.artistName);
|
||||
// }).then(function (infos) {
|
||||
// console.log(infos);
|
||||
// alltomp3.tagFile('./test.mp3', infos);
|
||||
// });
|
||||
|
||||
// alltomp3.downloadAndTagSingleURL(
|
||||
// 'https://www.youtube.com/watch?v=sX9s-bSOYxk',
|
||||
// './',
|
||||
// function (infos) {
|
||||
// console.log(infos);
|
||||
// },
|
||||
// undefined,
|
||||
// true,
|
||||
// );
|
||||
|
||||
// var title = "hide and seek imogen heap";
|
||||
// alltomp3.findVideo(title).then(function(results) {
|
||||
// var dl = alltomp3.downloadAndTagSingleURL(results[0].url, function(infos) {
|
||||
// console.log("FINI ", infos);
|
||||
// }, title);
|
||||
// dl.on('download', function(infos) {
|
||||
// process.stdout.cursorTo(0);
|
||||
// process.stdout.clearLine(1);
|
||||
// process.stdout.write(infos.progress + '%');
|
||||
// });
|
||||
// dl.on('download-end', function() {
|
||||
// console.log('Download end');
|
||||
// });
|
||||
// dl.on('convert', function(infos) {
|
||||
// process.stdout.cursorTo(0);
|
||||
// process.stdout.clearLine(1);
|
||||
// process.stdout.write(infos.progress + '%');
|
||||
// });
|
||||
// dl.on('convert-end', function() {
|
||||
// console.log('Convert end');
|
||||
// });
|
||||
// dl.on('infos', function(infos) {
|
||||
// console.log('Got infos: ', infos);
|
||||
// });
|
||||
// });
|
||||
|
||||
// var dl = alltomp3.downloadAndTagSingleURL("https://soundcloud.com/user-523607375/sets/john-legend-start-a-fire-la-la", 'mp3/', function(infos) {
|
||||
// console.log("FINI ", infos);
|
||||
// });
|
||||
// dl.on('download', function(infos) {
|
||||
// process.stdout.cursorTo(0);
|
||||
// process.stdout.clearLine(1);
|
||||
// process.stdout.write(infos.progress + '%');
|
||||
// });
|
||||
// dl.on('download-end', function() {
|
||||
// console.log('Download end');
|
||||
// });
|
||||
// dl.on('convert', function(infos) {
|
||||
// process.stdout.cursorTo(0);
|
||||
// process.stdout.clearLine(1);
|
||||
// process.stdout.write(infos.progress + '%');
|
||||
// });
|
||||
// dl.on('convert-end', function() {
|
||||
// console.log('Convert end');
|
||||
// });
|
||||
// dl.on('infos', function(infos) {
|
||||
// console.log('Got infos: ', infos);
|
||||
// });
|
||||
|
||||
var dl = alltomp3.findAndDownload('imagine dragons on top of the world', './mp3/', function (infos) {
|
||||
console.log("It's finished: ", infos);
|
||||
});
|
||||
dl.on('search-end', function () {
|
||||
console.log('Search end');
|
||||
});
|
||||
dl.on('download', function (infos) {
|
||||
process.stdout.cursorTo(0);
|
||||
process.stdout.clearLine(1);
|
||||
process.stdout.write(infos.progress + '%');
|
||||
});
|
||||
dl.on('download-end', function () {
|
||||
console.log('', 'Download end');
|
||||
});
|
||||
dl.on('convert', function (infos) {
|
||||
process.stdout.cursorTo(0);
|
||||
process.stdout.clearLine(1);
|
||||
process.stdout.write(infos.progress + '%');
|
||||
});
|
||||
dl.on('convert-end', function () {
|
||||
console.log('', 'Convert end');
|
||||
});
|
||||
dl.on('infos', function (infos) {
|
||||
console.log('New infos received: ', infos);
|
||||
});
|
||||
|
||||
// alltomp3.guessTrackFromString('Imagine Dragons - On Top of the World - Lyrics').then(function(infos) {
|
||||
// console.log(infos);
|
||||
// });
|
||||
// alltomp3.guessTrackFromString('C2C - Happy Ft. D.Martin').then(function(infos) {
|
||||
// console.log(infos);
|
||||
// });
|
||||
// alltomp3.guessTrackFromString('David Guetta - Bang My Head (Official Video) feat Sia & Fetty Wap').then(function(infos) {
|
||||
// console.log(infos);
|
||||
// });
|
||||
// alltomp3.guessTrackFromString('David Guetta - Hey Mama (Official Video) ft Nicki Minaj, Bebe Rexha & Afrojack').then(function(infos) {
|
||||
// console.log(infos);
|
||||
// });
|
||||
// alltomp3.guessTrackFromString('hans zimmer no time for caution').then(function(infos) {
|
||||
// console.log(infos);
|
||||
// });
|
||||
|
||||
// alltomp3.findLyrics('Radioactive', 'Imagine Dragons').then(function (lyrics) {
|
||||
// console.log(lyrics);
|
||||
// }).catch(function() {
|
||||
// console.log('No lyrics');
|
||||
// });
|
||||
|
||||
// alltomp3.getURLsInPlaylist('https://soundcloud.com/20syl/sets/20syl-remixes-2016').then(function(items) {
|
||||
// console.log(items);
|
||||
// });
|
||||
|
||||
// alltomp3.getTracksInPlaylist('http://www.deezer.com/album/11111444').then(function(items) {
|
||||
// console.log(items);
|
||||
// });
|
||||
|
||||
// var urls;
|
||||
// var dl = alltomp3.downloadPlaylist("https://open.spotify.com/album/2tVnLYqhc0iGdSCLxoaLjD", "./mp3/", function (urls) {
|
||||
// console.log("It's finished: ", urls);
|
||||
// }, 8);
|
||||
// dl.on('search-end', function() {
|
||||
// console.log('Search end');
|
||||
// });
|
||||
// dl.on('download', function(index) {
|
||||
// process.stdout.cursorTo(0);
|
||||
// process.stdout.clearLine(1);
|
||||
// process.stdout.write(urls.items[index].progress.download.progress + '%');
|
||||
// });
|
||||
// dl.on('download-end', function() {
|
||||
// console.log('', 'Download end');
|
||||
// });
|
||||
// dl.on('convert', function(index) {
|
||||
// process.stdout.cursorTo(0);
|
||||
// process.stdout.clearLine(1);
|
||||
// process.stdout.write(urls.items[index].progress.convert.progress + '%');
|
||||
// });
|
||||
// dl.on('convert-end', function(index) {
|
||||
// console.log('', 'Convert end');
|
||||
// });
|
||||
// dl.on('error', function(index) {
|
||||
// console.log('', 'Error with ' + index);
|
||||
// });
|
||||
// dl.on('infos', function(index) {
|
||||
// // console.log('New infos received: ', infos);
|
||||
// });
|
||||
// dl.on('playlist-infos', function(urlss) {
|
||||
// urls = urlss;
|
||||
// console.log('URLs received: ', urlss);
|
||||
// });
|
||||
// dl.on('begin-url', function(index) {
|
||||
// console.log('Begin: ', index);
|
||||
// });
|
||||
// dl.on('end-url', function(index) {
|
||||
// console.log('End: ', index);
|
||||
// });
|
Loading…
Reference in New Issue