Initial commit
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
commit
c593ef5871
|
@ -0,0 +1,20 @@
|
||||||
|
kind: pipeline
|
||||||
|
name: default
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: publish
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
username:
|
||||||
|
from_secret: docker_username
|
||||||
|
password:
|
||||||
|
from_secret: docker_password
|
||||||
|
repo: quay.io/jlelse/tiktokjson
|
||||||
|
registry: quay.io
|
||||||
|
tags: latest
|
||||||
|
when:
|
||||||
|
branch:
|
||||||
|
- master
|
||||||
|
event:
|
||||||
|
exclude:
|
||||||
|
- pull_request
|
|
@ -0,0 +1,2 @@
|
||||||
|
package-lock.json
|
||||||
|
node_modules
|
|
@ -0,0 +1,11 @@
|
||||||
|
FROM node:14-alpine
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY package.json ./
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY index.js .
|
||||||
|
|
||||||
|
EXPOSE 8080
|
||||||
|
CMD [ "node", "index.js" ]
|
|
@ -0,0 +1,43 @@
|
||||||
|
const express = require('express')
|
||||||
|
const scraper = require('tiktok-scraper');
|
||||||
|
|
||||||
|
const app = express()
|
||||||
|
const port = 8080
|
||||||
|
|
||||||
|
app.get('/user/:user', async (req, res) => {
|
||||||
|
let user = req.params.user
|
||||||
|
if (user && user.length != 0) {
|
||||||
|
try {
|
||||||
|
let feed = {
|
||||||
|
"version": "https://jsonfeed.org/version/1",
|
||||||
|
"title": `TikTok user @${user}`,
|
||||||
|
"home_page_url": `https://tiktok.com/@${user}`,
|
||||||
|
"items": []
|
||||||
|
}
|
||||||
|
let posts = await scraper.user(user, { number: 10 })
|
||||||
|
for (const post of posts.collector) {
|
||||||
|
feed.items.push({
|
||||||
|
"id": post.id,
|
||||||
|
"title": post.text,
|
||||||
|
"content_text": post.text,
|
||||||
|
"url": post.webVideoUrl,
|
||||||
|
"date_published": new Date(parseInt(post.createTime, 10) * 1000),
|
||||||
|
"attachments": [
|
||||||
|
{
|
||||||
|
"url": post.videoUrl,
|
||||||
|
"mime_type": "video/mp4"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
res.send(feed)
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error)
|
||||||
|
res.status(500).send(JSON.stringify(error))
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.status(403)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
app.listen(port, () => console.log(`Listening at http://localhost:${port}`))
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "tiktokrss",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "TikTok to JSON Feed",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node index.js"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.jlel.se/jlelse/TikTokJsonFeed.git"
|
||||||
|
},
|
||||||
|
"author": "jlelse",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.17.1",
|
||||||
|
"tiktok-scraper": "^1.1.10"
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue