Daniel Miller

Daniel Miller

// Menu: Genius Lyrics Search
let Genius = await npm('genius-lyrics-api')
let geniusUserToken = await env("GENIUS_AUTH_TOKEN")
import { getLyrics, searchSong } from 'genius-lyrics-api';
let songTitle = await arg("Song Title")
let options = {
apiKey: geniusUserToken,
title: songTitle,
artist: '',
optimizeQuery: true
}
let returnedSongs = await(searchSong(options).then((r) => r))
let returnedSongTitles = returnedSongs.map(s => s.title)
let chosenSongTitle = await arg("Which song?", returnedSongTitles)
let songData = returnedSongs.filter(s => s.title == chosenSongTitle)
let lyrics = await(getLyrics(songData[0].url).then((r) => r))
let whatToDo = await arg("", ["Copy", "View", "Visit"])
if (whatToDo == "Copy") copy(lyrics)
else if (whatToDo == "View") await textarea(lyrics)
else if (whatToDo == "Visit") await focusTab(songData[0].url)
let notionToken = await env('NOTION_USER_TOKEN')
let databaseID = "3859b567fda3464ea5a69d5ccb56274b"
let {data} = await post(
`https://api.notion.com/v1/databases/${databaseID}/query`,
{
"filter": {
"and": [
{
"property": "Status",
"select": {
"does_not_equal": "Done"
}
},
{
"property": "Status",
"select": {
"does_not_equal": "Archive"
}
}
]
},
page_size: 100
},
{
headers: {
Authorization: `Bearer ${notionToken}`,
"Content-Type": "application/json",
"Notion-Version": "2021-05-13"
}
})
let tasks = data.results
let task = tasks[Math.floor(Math.random() * tasks.length)];
let pageID = task.id.replace(/-/g, "");
let pageURL = `https://notion.so/${databaseID}?p=${pageID}`
copy(pageURL)
await focusTab(pageURL, "Google Chrome Beta")
let notionToken = await env('NOTION_USER_TOKEN')
let databaseID = "3859b567fda3464ea5a69d5ccb56274b"
let {data} = await post(
`https://api.notion.com/v1/databases/${databaseID}/query`,
{
"filter":
{
"property": "Status",
"select": {
"is_empty": true
}
},
page_size: 50
},
{
headers: {
Authorization: `Bearer ${notionToken}`,
"Content-Type": "application/json",
"Notion-Version": "2021-05-13"
}
})
let tasks = data.results
let task = tasks[Math.floor(Math.random() * tasks.length)];
let pageID = task.id.replace(/-/g, "");
let pageURL = `https://notion.so/${databaseID}?p=${pageID}`
copy(pageURL)
await focusTab(pageURL, "Google Chrome Beta")
<img width="418" alt="Screen Shot 2021-05-19 at 11 06 46 PM" src="https://user-images.githubusercontent.com/124208/118917657-f8c41e00-b8f6-11eb-9c5d-de7be826ec4c.png">
let notionToken = await env('NOTION_USER_TOKEN')
let databaseID = "3859b567fda3464ea5a69d5ccb56274b"
let content = await arg('Enter Task')
let {data} = await post(
'https://api.notion.com/v1/pages', {
"parent": { "database_id": databaseID },
"properties": {
"Name": {
"title": [
{
"text": {
"content": content
}
}
]
}
}
},
{
headers: {
Authorization: `Bearer ${notionToken}`,
}
})
let pageID = data.id.replace(/-/g, "");
let pageURL = `https://notion.so/${databaseID}?p=${pageID}`
copy(pageURL)
let notionToken = await env('NOTION_USER_TOKEN')
let databaseID = "3859b567fda3464ea5a69d5ccb56274b"
let content = await arg('Enter Task')
let {data} = await post(
'https://api.notion.com/v1/pages', {
"parent": { "database_id": databaseID },
"properties": {
"Name": {
"title": [
{
"text": {
"content": content
}
}
]
}
}
},
{
headers: {
Authorization: `Bearer ${notionToken}`,
"Content-Type": "application/json",
"Notion-Version": "2021-05-13"
}
})
let bodyContent = await arg('Enter Content')
let {bodyData} = await patch(
`https://api.notion.com/v1/blocks/${data.id}/children`, {
"children": [
{
"object": "block",
"type": "paragraph",
"paragraph": {
"text": [
{
"type": "text",
"text": {
"content": bodyContent
}
}
]
}
}
]
},
{
headers: {
Authorization: `Bearer ${notionToken}`,
"Content-Type": "application/json",
"Notion-Version": "2021-05-13"
}
})
let pageID = data.id.replace(/-/g, "");
let pageURL = `https://notion.so/${databaseID}?p=${pageID}`
copy(pageURL)