Skip to content

Commit

Permalink
soundcloud and prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
thoriqazzikraa committed Sep 23, 2023
1 parent e8757f7 commit 333efee
Show file tree
Hide file tree
Showing 8 changed files with 518 additions and 588 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
package.json
package-lock.json
11 changes: 11 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** @type {import("prettier").Config} */
const config = {
trailingComma: "none",
tabWidth: 2,
semi: false,
singleQuote: false,
bracketSpacing: true,
printWidth: 200
}

module.exports = config
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Install
`npm i scrape-websitee`
```
npm i scrape-websitee
```

# Usage
```js
Expand All @@ -17,6 +19,7 @@ const scrape = require("scrape-websitee")
ttsModel,
},
downloader: {
soundcloud, // (url)
spotify, // (url)
igStory, // (username)
twitterdl2, // (url)
Expand Down
28 changes: 14 additions & 14 deletions anime/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
const axios = require("axios");
const axios = require("axios")

async function neko() {
try {
const { data } = await axios.get("https://api.waifu.pics/sfw/neko");
return data;
const { data } = await axios.get("https://api.waifu.pics/sfw/neko")
return data
} catch (err) {
console.log(err);
return String(err);
console.log(err)
return String(err)
}
}

async function waifu() {
try {
const { data } = await axios.get("https://api.waifu.pics/sfw/waifu");
return data;
const { data } = await axios.get("https://api.waifu.pics/sfw/waifu")
return data
} catch (err) {
console.log(err);
return String(err);
console.log(err)
return String(err)
}
}

async function shinobu() {
try {
const { data } = await axios.get("https://api.waifu.pics/sfw/shinobu");
return data;
const { data } = await axios.get("https://api.waifu.pics/sfw/shinobu")
return data
} catch (err) {
console.log(err);
return String(err);
console.log(err)
return String(err)
}
}

module.exports = { neko, waifu, shinobu };
module.exports = { neko, waifu, shinobu }
8 changes: 2 additions & 6 deletions function/isUrl.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
function isUrl(url) {
return url.match(
new RegExp(
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/gi
)
);
return url.match(new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/gi))
}

module.exports = { isUrl };
module.exports = { isUrl }
44 changes: 22 additions & 22 deletions function/number.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
var SI_SYMBOL = ["", "K", "M", "G", "T", "P", "E"];
var SI_SYMBOL = ["", "K", "M", "G", "T", "P", "E"]

function convertMs(duration) {
seconds = parseInt((duration/1000)%60)
minutes = parseInt((duration/(1000*60))%60)
hours = parseInt((duration/(1000*60*60))%24);
hours = (hours < 10) ? "0" + hours : hours;
minutes = (minutes < 10) ? "0" + minutes : minutes;
seconds = (seconds < 10) ? "0" + seconds : seconds;
seconds = parseInt((duration / 1000) % 60)
minutes = parseInt((duration / (1000 * 60)) % 60)
hours = parseInt((duration / (1000 * 60 * 60)) % 24)
hours = hours < 10 ? "0" + hours : hours
minutes = minutes < 10 ? "0" + minutes : minutes
seconds = seconds < 10 ? "0" + seconds : seconds
return hours + ":" + minutes + ":" + seconds
}

function convertSec(sec) {
var hours = Math.floor(sec / 3600);
hours >= 1 ? (sec = sec - hours * 3600) : (hours = "00");
var min = Math.floor(sec / 60);
min >= 1 ? (sec = sec - min * 60) : (min = "00");
sec < 1 ? (sec = "00") : void 0;
min.toString().length == 1 ? (min = "0" + min) : void 0;
sec.toString().length == 1 ? (sec = "0" + sec) : void 0;
return hours + ":" + min + ":" + sec;
var hours = Math.floor(sec / 3600)
hours >= 1 ? (sec = sec - hours * 3600) : (hours = "00")
var min = Math.floor(sec / 60)
min >= 1 ? (sec = sec - min * 60) : (min = "00")
sec < 1 ? (sec = "00") : void 0
min.toString().length == 1 ? (min = "0" + min) : void 0
sec.toString().length == 1 ? (sec = "0" + sec) : void 0
return hours + ":" + min + ":" + sec
}

function convertNum(number) {
// what tier? (determines SI symbol)
var tier = (Math.log10(Math.abs(number)) / 3) | 0;
var tier = (Math.log10(Math.abs(number)) / 3) | 0
// if zero, we don't need a suffix
if (tier == 0) return number;
if (tier == 0) return number
// get suffix and determine scale
var suffix = SI_SYMBOL[tier];
var scale = Math.pow(10, tier * 3);
var suffix = SI_SYMBOL[tier]
var scale = Math.pow(10, tier * 3)
// scale the number
var scaled = number / scale;
var scaled = number / scale
// format number and add suffix
return scaled.toFixed(1) + suffix;
return scaled.toFixed(1) + suffix
}

module.exports = { convertNum, convertSec, convertMs };
module.exports = { convertNum, convertSec, convertMs }
Loading

0 comments on commit 333efee

Please sign in to comment.