Skip to content

Commit

Permalink
remove the database again
Browse files Browse the repository at this point in the history
  • Loading branch information
konsumer committed Jan 20, 2021
1 parent 46fcef1 commit 9293b90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 89 deletions.
66 changes: 0 additions & 66 deletions build_postgres.js

This file was deleted.

14 changes: 0 additions & 14 deletions db.js

This file was deleted.

19 changes: 10 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ This is a very simple proxy that tries to pick the right mirror for a video ID.

const express = require('express')
const ytdl = require('ytdl-core')
const db = require('./db')

const { PORT = 5000 } = process.env
const mirrors = {
...require('./data/mirror3.json'),
...require('./data/mirror2.json'),
...require('./data/mirror1.json')
}

db.connect()
const { PORT = 5000 } = process.env

express()
// show the map
Expand All @@ -29,13 +32,11 @@ express()
if (!id) {
throw new Error('No id.')
}
const r = await db.query('SELECT url FROM mirrors WHERE id=$1 LIMIT 1', [id])
if (r && r.rows && r.rows[0]) {
console.log(`${id} URL found: ${r.rows[0].url}`)
return res.redirect(301, r.rows[0].url)

if (mirrors[id]) {
return res.redirect(301, mirrors[id])
} else {
console.log(`No video URL found for ${id}`)
res.status(404).type('txt').send('Not found')
return res.redirect(301, `https://pl.gammaspectra.live/video.parler.com/${id.substr(0,2)}/${id.substr(2,2)}/${id}`)
}
})

Expand Down

0 comments on commit 9293b90

Please sign in to comment.