Skip to content

Instantly share code, notes, and snippets.

@shd101wyy
Last active June 30, 2018 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save shd101wyy/d24870fd17f76e17eb420cf6472fe5b6 to your computer and use it in GitHub Desktop.
Save shd101wyy/d24870fd17f76e17eb420cf6472fe5b6 to your computer and use it in GitHub Desktop.
My moni script
(function(args={}) { // event = {url, cheerio, $get}
return new Promise((resolve, reject)=> {
const name = args['name']
const url = encodeURI(`http://www.fixsub.com/portfolio/${name}`)
request.get({
url,
headers: {
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36'
}
}, function(error, response, body) {
if (error) return reject(error.toString())
const $ = cheerio.load(body, {decodeEntities: false})
const cover = $('.img-frame').last().attr('src')
const contentBox = $('.content-box')
const newestSeason = $('p', contentBox).last().prev().text()
const newestDownload = $('p', contentBox).last().html()
return resolve({
link: url,
cover,
newestDownload,
newestSeason
})
})
})
})
(function (args) {
return new Promise((resolve, reject)=> {
const userId = args['userId'],
repositoryName = args['repositoryName']
const url = `https://github.com/${userId}/${repositoryName}`
request.get({url}, (error, response, body)=> {
if (error) return reject(error.toString())
const $ = cheerio.load(body)
let title = $('title').text()
const i = title.indexOf(':')
const watchers = parseInt($($('.social-count')[0]).text().trim()),
stars = parseInt($($('.social-count')[1]).text().trim()),
forks = parseInt($($('.social-count')[2]).text().trim()),
issues = parseInt($($('.Counter')[0]).text().trim()),
pullRequests = parseInt($($('.Counter')[1]).text().trim())
const description = title.slice(i+1, title.length).trim() + '\n\n' +
watchers + ' watchers\n' +
stars + ' stars; ' + forks + ' forks\n' +
issues + ' issues; ' + pullRequests + ' pull requests\n'
title = title.slice(0, i).trim()
const j = title.indexOf('/'),
k = title.indexOf('-')
const projectName = title.slice(j+1, title.length),
authorName = title.slice(k+1, j).trim()
return resolve({
title: title,
description,
link: url,
favicon: "https://github.com/favicon.ico",
watchers,
stars,
issues,
pullRequests,
forks
})
})
})
})
module.exports = {
"plugins": [
],
"localPlugins": [
],
"config": {
"port": 3003,
"debug": true
},
"tasks": {
"Hello World": {
"trigger": ["console", "sayHi"],
"action": [
["console", "log", "${msg}"]
]
},
"史丹利 Studio": {
"trigger": ["crawler", "runScript", {
"script": "[bilibili]",
"url": "http://space.bilibili.com/7349#!/"
}, {"interval": "30m"}],
"action": [
["email", "sendEmail", {
"to": "shd101wyy@gmail.com",
"subject": "${$taskId}",
"html": "${title} <br><br> ${link}"
}]
]
},
"敖厂长": {
"trigger": ["crawler", "runScript", {
"script": "[bilibili]",
"url": "http://space.bilibili.com/122879#!/"
}, {"interval": "30m"}],
"action": [
["email", "sendEmail", {
"to": "shd101wyy@gmail.com",
"subject": "${$taskId}",
"html": "${title} <br><br> ${link}"
}]
]
},
"火影忍者-博人传": {
"trigger": ["crawler", "runScript", {
"script": "[bilibili]",
"url": "http://bangumi.bilibili.com/anime/5978/"
}, {"interval": "30m"}],
"action": [
["email", "sendEmail", {
"to": "shd101wyy@gmail.com",
"subject": "火影忍者博人转 更新",
"html": "${description} <br><br> ${link}"
}]
]
},
"逍遥游 小说更新": {
"trigger": ["crawler", "runScript", {
"script": "[piaotian]",
"url": "http://m.piaotian.com/book/8567.html"
}, {"interval": "15m"}],
"action": [
/* ["console", "log", "${this}"], */
["email", "sendEmail", {
"to": "shd101wyy@gmail.com",
"subject": "逍遥游 小说更新",
"html": "${description} <br><br> ${link}"
}]
]
},
// my github repo information
"(GitHub) Markdown Preview Enhanced": {
"trigger": ["crawler", "runScript", {
"script": "https://gist.githubusercontent.com/shd101wyy/d24870fd17f76e17eb420cf6472fe5b6/raw/9dddf4615e748d67e142afc60168e1a50028e270/github.js",
"userId": "shd101wyy",
"repositoryName": "markdown-preview-enhanced",
}, {"interval": "20m"}],
"action": [
// ["console", "log", "${this}"],
["email", "sendEmail", {
"to": "shd101wyy@gmail.com",
"subject": "${$taskId}",
"html": "${description} <br><br> ${link}"
}]
]
},
"(GitHub) VSCode Markdown Preview Enhanced": {
"trigger": ["crawler", "runScript", {
"script": "https://gist.githubusercontent.com/shd101wyy/d24870fd17f76e17eb420cf6472fe5b6/raw/9dddf4615e748d67e142afc60168e1a50028e270/github.js",
"userId": "shd101wyy",
"repositoryName": "vscode-markdown-preview-enhanced",
}, {"interval": "20m"}],
"action": [
// ["console", "log", "${this}"],
["email", "sendEmail", {
"to": "shd101wyy@gmail.com",
"subject": "${$taskId}",
"html": "${description} <br><br> ${link}"
}]
]
},
// fixsub
"权力的游戏 Fix字幕组更新": {
"trigger": ["crawler", "runScript", {
"script": "https://gist.githubusercontent.com/shd101wyy/d24870fd17f76e17eb420cf6472fe5b6/raw/405007ef9d47b173ee6b5143a8c4abaa1e933509/fixsub.js",
"name": "权力的游戏"
}, {"interval": "30m"}],
"action": [
// ["console", "log", "${this}"],
["email", "sendEmail", {
"to": "shd101wyy@gmail.com",
"subject": "权力的游戏 ${newestSeason}",
"html": `
<img src="\${cover}"> <br><br>
<a>入口</a> <br><br>
\${newestDownload}`
}]
]
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment