Upload 147 files
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .circleci/config.yml +18 -0
- .dockerignore +11 -0
- .github/ISSUE_TEMPLATE/bug_report.md +37 -0
- .github/ISSUE_TEMPLATE/feature_request.md +20 -0
- .github/dependabot.yml +12 -0
- .github/workflows/docker-build.yml +133 -0
- .gitignore +161 -0
- Dockerfile +37 -0
- LICENSE +619 -0
- README.md +186 -12
- SELF-HOSTING.md +377 -0
- app/__init__.py +14 -0
- app/cache/.ignore +1 -0
- app/errors.py +16 -0
- app/favicon.png +0 -0
- app/forms.py +36 -0
- app/models.py +178 -0
- app/routes.py +1070 -0
- app/static/favicon_io.zip +3 -0
- app/static/favicons/android-chrome-192x192.png +0 -0
- app/static/favicons/android-chrome-512x512.png +0 -0
- app/static/favicons/apple-touch-icon.png +0 -0
- app/static/favicons/favicon-16x16.png +0 -0
- app/static/favicons/favicon-32x32.png +0 -0
- app/static/favicons/favicon.ico +0 -0
- app/static/favicons/site.webmanifest +1 -0
- app/static/img/404.png +0 -0
- app/static/img/405.png +0 -0
- app/static/img/500.png +0 -0
- app/static/img/avatars/1.png +0 -0
- app/static/img/avatars/10.png +0 -0
- app/static/img/avatars/11.png +0 -0
- app/static/img/avatars/12.png +0 -0
- app/static/img/avatars/2.png +0 -0
- app/static/img/avatars/3.png +0 -0
- app/static/img/avatars/4.png +0 -0
- app/static/img/avatars/5.png +0 -0
- app/static/img/avatars/6.png +0 -0
- app/static/img/avatars/7.png +0 -0
- app/static/img/avatars/8.png +0 -0
- app/static/img/avatars/9.png +0 -0
- app/static/img/banner.png +0 -0
- app/static/img/close.png +0 -0
- app/static/img/closed.png +0 -0
- app/static/img/empty.png +0 -0
- app/static/img/live.png +0 -0
- app/static/img/logo.png +0 -0
- app/static/img/logo_new.png +0 -0
- app/static/img/logo_new.svg +29 -0
- app/static/img/logo_simple.png +0 -0
.circleci/config.yml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2.1
|
2 |
+
|
3 |
+
orbs:
|
4 |
+
python: circleci/[email protected]
|
5 |
+
|
6 |
+
jobs:
|
7 |
+
build-and-test:
|
8 |
+
executor: python/default
|
9 |
+
steps:
|
10 |
+
- checkout
|
11 |
+
- python/install-packages:
|
12 |
+
pkg-manager: pip
|
13 |
+
# TODO: Tests
|
14 |
+
|
15 |
+
workflows:
|
16 |
+
main:
|
17 |
+
jobs:
|
18 |
+
- build-and-test
|
.dockerignore
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.circleci
|
2 |
+
.git
|
3 |
+
.github
|
4 |
+
.gitignore
|
5 |
+
cache
|
6 |
+
Dockerfile
|
7 |
+
docker-compose.yml
|
8 |
+
LICENSE
|
9 |
+
*.md
|
10 |
+
dockerhash.txt
|
11 |
+
app/static
|
.github/ISSUE_TEMPLATE/bug_report.md
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Bug report
|
3 |
+
about: Create a report to help us improve
|
4 |
+
title: ''
|
5 |
+
labels: bug
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
**Describe the bug**
|
11 |
+
A clear and concise description of what the bug is.
|
12 |
+
|
13 |
+
**To Reproduce**
|
14 |
+
Steps to reproduce the behavior:
|
15 |
+
1. Go to '...'
|
16 |
+
2. Click on '....'
|
17 |
+
3. Scroll down to '....'
|
18 |
+
4. See error
|
19 |
+
|
20 |
+
**Expected behavior**
|
21 |
+
A clear and concise description of what you expected to happen.
|
22 |
+
|
23 |
+
**Screenshots**
|
24 |
+
If applicable, add screenshots to help explain your problem.
|
25 |
+
|
26 |
+
**Desktop (please complete the following information):**
|
27 |
+
- OS: [e.g. iOS]
|
28 |
+
- Browser [e.g. chrome, safari]
|
29 |
+
- Version [e.g. 22]
|
30 |
+
|
31 |
+
**Smartphone (please complete the following information):**
|
32 |
+
- OS: [e.g. iOS8.1]
|
33 |
+
- Browser [e.g. stock browser, safari]
|
34 |
+
- Version [e.g. 22]
|
35 |
+
|
36 |
+
**Additional context**
|
37 |
+
Add any other context about the problem here.
|
.github/ISSUE_TEMPLATE/feature_request.md
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
name: Feature request
|
3 |
+
about: Suggest an idea for this project
|
4 |
+
title: ''
|
5 |
+
labels: feature request
|
6 |
+
assignees: ''
|
7 |
+
|
8 |
+
---
|
9 |
+
|
10 |
+
**Is your feature request related to a problem? Please describe.**
|
11 |
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
12 |
+
|
13 |
+
**Describe the solution you'd like**
|
14 |
+
A clear and concise description of what you want to happen.
|
15 |
+
|
16 |
+
**Describe alternatives you've considered**
|
17 |
+
A clear and concise description of any alternative solutions or features you've considered.
|
18 |
+
|
19 |
+
**Additional context**
|
20 |
+
Add any other context or screenshots about the feature request here.
|
.github/dependabot.yml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
version: 2
|
2 |
+
updates:
|
3 |
+
# Maintain dependencies for GitHub Actions
|
4 |
+
- package-ecosystem: "github-actions"
|
5 |
+
directory: "/"
|
6 |
+
schedule:
|
7 |
+
interval: "daily"
|
8 |
+
# Maintain dependencies for pip
|
9 |
+
- package-ecosystem: "pip"
|
10 |
+
directory: "/"
|
11 |
+
schedule:
|
12 |
+
interval: "daily"
|
.github/workflows/docker-build.yml
ADDED
@@ -0,0 +1,133 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
name: Docker Multi-Architecture Build
|
2 |
+
|
3 |
+
on:
|
4 |
+
push:
|
5 |
+
paths-ignore:
|
6 |
+
- "**.md"
|
7 |
+
branches:
|
8 |
+
- dev-indep
|
9 |
+
|
10 |
+
jobs:
|
11 |
+
cpython-build-docker:
|
12 |
+
runs-on: ubuntu-latest
|
13 |
+
steps:
|
14 |
+
- uses: actions/[email protected]
|
15 |
+
with:
|
16 |
+
fetch-depth: 0
|
17 |
+
- name: Set up QEMU
|
18 |
+
uses: docker/[email protected]
|
19 |
+
with:
|
20 |
+
platforms: all
|
21 |
+
- name: Set up Docker Buildx
|
22 |
+
id: buildx
|
23 |
+
uses: docker/[email protected]
|
24 |
+
with:
|
25 |
+
version: latest
|
26 |
+
- name: Login to DockerHub
|
27 |
+
uses: docker/[email protected]
|
28 |
+
with:
|
29 |
+
username: ${{ secrets.DOCKER_USERNAME }}
|
30 |
+
password: ${{ secrets.DOCKER_PASSWORD }}
|
31 |
+
- name: Get hash of latest image
|
32 |
+
run: docker pull python:3-alpine && docker inspect --format='{{index .RepoDigests 0}}' python:3-alpine > dockerhash.txt
|
33 |
+
- name: Write the current version to a file
|
34 |
+
run: "{ git describe --tags --abbrev=0 & date +\"%d-%m-%y\" & git rev-list HEAD --max-count=1 --abbrev-commit;} > version.txt"
|
35 |
+
- name: cache docker cache
|
36 |
+
uses: actions/[email protected]
|
37 |
+
with:
|
38 |
+
path: ${{ github.workspace }}/cache
|
39 |
+
key: ${{ runner.os }}-docker-cpython-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/dockerhash.txt') }}
|
40 |
+
restore-keys: |
|
41 |
+
${{ runner.os }}-docker-cpython-
|
42 |
+
- name: Build and push
|
43 |
+
uses: docker/[email protected]
|
44 |
+
with:
|
45 |
+
context: .
|
46 |
+
file: ./Dockerfile
|
47 |
+
platforms: linux/amd64,linux/arm64
|
48 |
+
push: true
|
49 |
+
tags: ytorg/yotter:latest
|
50 |
+
cache-from: type=local,src=cache
|
51 |
+
cache-to: type=local,dest=cache
|
52 |
+
pypy-build-docker:
|
53 |
+
runs-on: ubuntu-latest
|
54 |
+
steps:
|
55 |
+
- uses: actions/[email protected]
|
56 |
+
with:
|
57 |
+
fetch-depth: 0
|
58 |
+
- name: Set up QEMU
|
59 |
+
uses: docker/[email protected]
|
60 |
+
with:
|
61 |
+
platforms: all
|
62 |
+
- name: Set up Docker Buildx
|
63 |
+
id: buildx
|
64 |
+
uses: docker/[email protected]
|
65 |
+
with:
|
66 |
+
version: latest
|
67 |
+
- name: Login to DockerHub
|
68 |
+
uses: docker/[email protected]
|
69 |
+
with:
|
70 |
+
username: ${{ secrets.DOCKER_USERNAME }}
|
71 |
+
password: ${{ secrets.DOCKER_PASSWORD }}
|
72 |
+
- name: Get hash of latest image
|
73 |
+
run: docker pull pypy:3-slim-buster && docker inspect --format='{{index .RepoDigests 0}}' pypy:3-slim-buster > dockerhash.txt
|
74 |
+
- name: Write the current version to a file
|
75 |
+
run: "{ git describe --tags --abbrev=0 & date +\"%d-%m-%y\" & git rev-list HEAD --max-count=1 --abbrev-commit;} > version.txt"
|
76 |
+
- name: cache docker cache
|
77 |
+
uses: actions/[email protected]
|
78 |
+
with:
|
79 |
+
path: ${{ github.workspace }}/cache
|
80 |
+
key: ${{ runner.os }}-docker-pypy-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/dockerhash.txt') }}
|
81 |
+
restore-keys: |
|
82 |
+
${{ runner.os }}-docker-pypy-
|
83 |
+
- name: Build and push
|
84 |
+
uses: docker/[email protected]
|
85 |
+
with:
|
86 |
+
context: .
|
87 |
+
file: ./pypy.Dockerfile
|
88 |
+
platforms: linux/amd64,linux/arm64
|
89 |
+
push: true
|
90 |
+
tags: ytorg/yotter:pypy
|
91 |
+
cache-from: type=local,src=cache
|
92 |
+
cache-to: type=local,dest=cache
|
93 |
+
nginx-build-docker:
|
94 |
+
runs-on: ubuntu-latest
|
95 |
+
steps:
|
96 |
+
- uses: actions/[email protected]
|
97 |
+
with:
|
98 |
+
fetch-depth: 0
|
99 |
+
- name: Set up QEMU
|
100 |
+
uses: docker/[email protected]
|
101 |
+
with:
|
102 |
+
platforms: all
|
103 |
+
- name: Set up Docker Buildx
|
104 |
+
id: buildx
|
105 |
+
uses: docker/[email protected]
|
106 |
+
with:
|
107 |
+
version: latest
|
108 |
+
- name: Login to DockerHub
|
109 |
+
uses: docker/[email protected]
|
110 |
+
with:
|
111 |
+
username: ${{ secrets.DOCKER_USERNAME }}
|
112 |
+
password: ${{ secrets.DOCKER_PASSWORD }}
|
113 |
+
- name: Get hash of latest image
|
114 |
+
run: docker pull nginx:mainline-alpine && docker inspect --format='{{index .RepoDigests 0}}' nginx:mainline-alpine > dockerhash.txt
|
115 |
+
- name: Write the current version to a file
|
116 |
+
run: "{ git describe --tags --abbrev=0 & date +\"%d-%m-%y\" & git rev-list HEAD --max-count=1 --abbrev-commit;} > version.txt"
|
117 |
+
- name: cache docker cache
|
118 |
+
uses: actions/[email protected]
|
119 |
+
with:
|
120 |
+
path: ${{ github.workspace }}/cache
|
121 |
+
key: ${{ runner.os }}-docker-nginx-${{ hashFiles('**/dockerhash.txt') }}
|
122 |
+
restore-keys: |
|
123 |
+
${{ runner.os }}-docker-nginx-
|
124 |
+
- name: Build and push
|
125 |
+
uses: docker/[email protected]
|
126 |
+
with:
|
127 |
+
context: .
|
128 |
+
file: ./Dockerfile
|
129 |
+
platforms: linux/amd64,linux/arm64
|
130 |
+
push: true
|
131 |
+
tags: ytorg/nginx:latest
|
132 |
+
cache-from: type=local,src=cache
|
133 |
+
cache-to: type=local,dest=cache
|
.gitignore
ADDED
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
# Created by https://www.toptal.com/developers/gitignore/api/python
|
3 |
+
# Edit at https://www.toptal.com/developers/gitignore?templates=python
|
4 |
+
|
5 |
+
### Python ###
|
6 |
+
# Byte-compiled / optimized / DLL files
|
7 |
+
__pycache__/
|
8 |
+
*.py[cod]
|
9 |
+
*$py.class
|
10 |
+
|
11 |
+
# C extensions
|
12 |
+
*.so
|
13 |
+
|
14 |
+
# Distribution / packaging
|
15 |
+
.Python
|
16 |
+
build/
|
17 |
+
develop-eggs/
|
18 |
+
dist/
|
19 |
+
downloads/
|
20 |
+
eggs/
|
21 |
+
.eggs/
|
22 |
+
lib/
|
23 |
+
lib64/
|
24 |
+
parts/
|
25 |
+
sdist/
|
26 |
+
var/
|
27 |
+
wheels/
|
28 |
+
pip-wheel-metadata/
|
29 |
+
share/python-wheels/
|
30 |
+
*.egg-info/
|
31 |
+
.installed.cfg
|
32 |
+
*.egg
|
33 |
+
MANIFEST
|
34 |
+
|
35 |
+
# PyInstaller
|
36 |
+
# Usually these files are written by a python script from a template
|
37 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
38 |
+
*.manifest
|
39 |
+
*.spec
|
40 |
+
|
41 |
+
# Installer logs
|
42 |
+
pip-log.txt
|
43 |
+
pip-delete-this-directory.txt
|
44 |
+
|
45 |
+
# Unit test / coverage reports
|
46 |
+
htmlcov/
|
47 |
+
.tox/
|
48 |
+
.nox/
|
49 |
+
.coverage
|
50 |
+
.coverage.*
|
51 |
+
.cache
|
52 |
+
nosetests.xml
|
53 |
+
coverage.xml
|
54 |
+
*.cover
|
55 |
+
*.py,cover
|
56 |
+
.hypothesis/
|
57 |
+
.pytest_cache/
|
58 |
+
|
59 |
+
# Translations
|
60 |
+
*.mo
|
61 |
+
*.pot
|
62 |
+
|
63 |
+
# Django stuff:
|
64 |
+
*.log
|
65 |
+
local_settings.py
|
66 |
+
db.sqlite3
|
67 |
+
db.sqlite3-journal
|
68 |
+
|
69 |
+
# Flask stuff:
|
70 |
+
instance/
|
71 |
+
.webassets-cache
|
72 |
+
|
73 |
+
# Scrapy stuff:
|
74 |
+
.scrapy
|
75 |
+
|
76 |
+
# Sphinx documentation
|
77 |
+
docs/_build/
|
78 |
+
|
79 |
+
# PyBuilder
|
80 |
+
target/
|
81 |
+
|
82 |
+
# Jupyter Notebook
|
83 |
+
.ipynb_checkpoints
|
84 |
+
|
85 |
+
# IPython
|
86 |
+
profile_default/
|
87 |
+
ipython_config.py
|
88 |
+
|
89 |
+
# pyenv
|
90 |
+
.python-version
|
91 |
+
|
92 |
+
# pipenv
|
93 |
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
94 |
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
95 |
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
96 |
+
# install all needed dependencies.
|
97 |
+
#Pipfile.lock
|
98 |
+
|
99 |
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
100 |
+
__pypackages__/
|
101 |
+
|
102 |
+
# Celery stuff
|
103 |
+
celerybeat-schedule
|
104 |
+
celerybeat.pid
|
105 |
+
|
106 |
+
# SageMath parsed files
|
107 |
+
*.sage.py
|
108 |
+
|
109 |
+
# Environments
|
110 |
+
.env
|
111 |
+
.venv
|
112 |
+
env/
|
113 |
+
venv/
|
114 |
+
ENV/
|
115 |
+
env.bak/
|
116 |
+
venv.bak/
|
117 |
+
|
118 |
+
# Migrations
|
119 |
+
migrations/
|
120 |
+
.migrations/
|
121 |
+
|
122 |
+
# Database
|
123 |
+
app.db
|
124 |
+
*.db
|
125 |
+
|
126 |
+
# Spyder project settings
|
127 |
+
.spyderproject
|
128 |
+
.spyproject
|
129 |
+
|
130 |
+
# Rope project settings
|
131 |
+
.ropeproject
|
132 |
+
|
133 |
+
# mkdocs documentation
|
134 |
+
/site
|
135 |
+
|
136 |
+
# mypy
|
137 |
+
.mypy_cache/
|
138 |
+
.dmypy.json
|
139 |
+
dmypy.json
|
140 |
+
|
141 |
+
# Pyre type checker
|
142 |
+
.pyre/
|
143 |
+
|
144 |
+
# pytype static type analyzer
|
145 |
+
.pytype/
|
146 |
+
|
147 |
+
# Added
|
148 |
+
data_export.json
|
149 |
+
.env
|
150 |
+
.envo
|
151 |
+
SELF-HOSTING.md
|
152 |
+
README.md
|
153 |
+
/misc
|
154 |
+
misc/*
|
155 |
+
/misc/*
|
156 |
+
app/cache/*
|
157 |
+
app/cache
|
158 |
+
./app/cache/*
|
159 |
+
./app/cache
|
160 |
+
.github/ISSUE_TEMPLATE/
|
161 |
+
.github/ISSUE_TEMPLATE/*
|
Dockerfile
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
FROM python:3-alpine AS base
|
2 |
+
|
3 |
+
# Image to Build Dependencies
|
4 |
+
FROM base AS builder
|
5 |
+
|
6 |
+
WORKDIR /usr/src/app
|
7 |
+
|
8 |
+
COPY ./requirements.txt /usr/src/app
|
9 |
+
|
10 |
+
# Build Dependencies
|
11 |
+
RUN apk --no-cache add gcc musl-dev libffi-dev openssl-dev libxml2-dev libxslt-dev file llvm-dev make g++ cargo rust
|
12 |
+
|
13 |
+
# Python Dependencies
|
14 |
+
RUN pip install --no-cache-dir --prefix=/install wheel cryptography gunicorn pymysql
|
15 |
+
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
|
16 |
+
|
17 |
+
# Runtime Environment Image
|
18 |
+
FROM base
|
19 |
+
|
20 |
+
WORKDIR /usr/src/app
|
21 |
+
|
22 |
+
# Runtime Dependencies
|
23 |
+
RUN apk --no-cache add libxml2 libxslt
|
24 |
+
COPY --from=builder /install /usr/local
|
25 |
+
|
26 |
+
COPY . .
|
27 |
+
|
28 |
+
RUN flask db init \
|
29 |
+
&& flask db migrate \
|
30 |
+
&& flask db upgrade
|
31 |
+
|
32 |
+
CMD flask db stamp head \
|
33 |
+
&& flask db migrate \
|
34 |
+
&& flask db upgrade \
|
35 |
+
&& gunicorn -b 0.0.0.0:5000 -w 4 yotter:app
|
36 |
+
|
37 |
+
EXPOSE 5000
|
LICENSE
ADDED
@@ -0,0 +1,619 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU AFFERO GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 19 November 2007
|
3 |
+
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
6 |
+
of this license document, but changing it is not allowed.
|
7 |
+
|
8 |
+
Preamble
|
9 |
+
|
10 |
+
The GNU Affero General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works, specifically designed to ensure
|
12 |
+
cooperation with the community in the case of network server software.
|
13 |
+
|
14 |
+
The licenses for most software and other practical works are designed
|
15 |
+
to take away your freedom to share and change the works. By contrast,
|
16 |
+
our General Public Licenses are intended to guarantee your freedom to
|
17 |
+
share and change all versions of a program--to make sure it remains free
|
18 |
+
software for all its users.
|
19 |
+
|
20 |
+
When we speak of free software, we are referring to freedom, not
|
21 |
+
price. Our General Public Licenses are designed to make sure that you
|
22 |
+
have the freedom to distribute copies of free software (and charge for
|
23 |
+
them if you wish), that you receive source code or can get it if you
|
24 |
+
want it, that you can change the software or use pieces of it in new
|
25 |
+
free programs, and that you know you can do these things.
|
26 |
+
|
27 |
+
Developers that use our General Public Licenses protect your rights
|
28 |
+
with two steps: (1) assert copyright on the software, and (2) offer
|
29 |
+
you this License which gives you legal permission to copy, distribute
|
30 |
+
and/or modify the software.
|
31 |
+
|
32 |
+
A secondary benefit of defending all users' freedom is that
|
33 |
+
improvements made in alternate versions of the program, if they
|
34 |
+
receive widespread use, become available for other developers to
|
35 |
+
incorporate. Many developers of free software are heartened and
|
36 |
+
encouraged by the resulting cooperation. However, in the case of
|
37 |
+
software used on network servers, this result may fail to come about.
|
38 |
+
The GNU General Public License permits making a modified version and
|
39 |
+
letting the public access it on a server without ever releasing its
|
40 |
+
source code to the public.
|
41 |
+
|
42 |
+
The GNU Affero General Public License is designed specifically to
|
43 |
+
ensure that, in such cases, the modified source code becomes available
|
44 |
+
to the community. It requires the operator of a network server to
|
45 |
+
provide the source code of the modified version running there to the
|
46 |
+
users of that server. Therefore, public use of a modified version, on
|
47 |
+
a publicly accessible server, gives the public access to the source
|
48 |
+
code of the modified version.
|
49 |
+
|
50 |
+
An older license, called the Affero General Public License and
|
51 |
+
published by Affero, was designed to accomplish similar goals. This is
|
52 |
+
a different license, not a version of the Affero GPL, but Affero has
|
53 |
+
released a new version of the Affero GPL which permits relicensing under
|
54 |
+
this license.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
TERMS AND CONDITIONS
|
60 |
+
|
61 |
+
0. Definitions.
|
62 |
+
|
63 |
+
"This License" refers to version 3 of the GNU Affero General Public License.
|
64 |
+
|
65 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
66 |
+
works, such as semiconductor masks.
|
67 |
+
|
68 |
+
"The Program" refers to any copyrightable work licensed under this
|
69 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
70 |
+
"recipients" may be individuals or organizations.
|
71 |
+
|
72 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
73 |
+
in a fashion requiring copyright permission, other than the making of an
|
74 |
+
exact copy. The resulting work is called a "modified version" of the
|
75 |
+
earlier work or a work "based on" the earlier work.
|
76 |
+
|
77 |
+
A "covered work" means either the unmodified Program or a work based
|
78 |
+
on the Program.
|
79 |
+
|
80 |
+
To "propagate" a work means to do anything with it that, without
|
81 |
+
permission, would make you directly or secondarily liable for
|
82 |
+
infringement under applicable copyright law, except executing it on a
|
83 |
+
computer or modifying a private copy. Propagation includes copying,
|
84 |
+
distribution (with or without modification), making available to the
|
85 |
+
public, and in some countries other activities as well.
|
86 |
+
|
87 |
+
To "convey" a work means any kind of propagation that enables other
|
88 |
+
parties to make or receive copies. Mere interaction with a user through
|
89 |
+
a computer network, with no transfer of a copy, is not conveying.
|
90 |
+
|
91 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
92 |
+
to the extent that it includes a convenient and prominently visible
|
93 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
94 |
+
tells the user that there is no warranty for the work (except to the
|
95 |
+
extent that warranties are provided), that licensees may convey the
|
96 |
+
work under this License, and how to view a copy of this License. If
|
97 |
+
the interface presents a list of user commands or options, such as a
|
98 |
+
menu, a prominent item in the list meets this criterion.
|
99 |
+
|
100 |
+
1. Source Code.
|
101 |
+
|
102 |
+
The "source code" for a work means the preferred form of the work
|
103 |
+
for making modifications to it. "Object code" means any non-source
|
104 |
+
form of a work.
|
105 |
+
|
106 |
+
A "Standard Interface" means an interface that either is an official
|
107 |
+
standard defined by a recognized standards body, or, in the case of
|
108 |
+
interfaces specified for a particular programming language, one that
|
109 |
+
is widely used among developers working in that language.
|
110 |
+
|
111 |
+
The "System Libraries" of an executable work include anything, other
|
112 |
+
than the work as a whole, that (a) is included in the normal form of
|
113 |
+
packaging a Major Component, but which is not part of that Major
|
114 |
+
Component, and (b) serves only to enable use of the work with that
|
115 |
+
Major Component, or to implement a Standard Interface for which an
|
116 |
+
implementation is available to the public in source code form. A
|
117 |
+
"Major Component", in this context, means a major essential component
|
118 |
+
(kernel, window system, and so on) of the specific operating system
|
119 |
+
(if any) on which the executable work runs, or a compiler used to
|
120 |
+
produce the work, or an object code interpreter used to run it.
|
121 |
+
|
122 |
+
The "Corresponding Source" for a work in object code form means all
|
123 |
+
the source code needed to generate, install, and (for an executable
|
124 |
+
work) run the object code and to modify the work, including scripts to
|
125 |
+
control those activities. However, it does not include the work's
|
126 |
+
System Libraries, or general-purpose tools or generally available free
|
127 |
+
programs which are used unmodified in performing those activities but
|
128 |
+
which are not part of the work. For example, Corresponding Source
|
129 |
+
includes interface definition files associated with source files for
|
130 |
+
the work, and the source code for shared libraries and dynamically
|
131 |
+
linked subprograms that the work is specifically designed to require,
|
132 |
+
such as by intimate data communication or control flow between those
|
133 |
+
subprograms and other parts of the work.
|
134 |
+
|
135 |
+
The Corresponding Source need not include anything that users
|
136 |
+
can regenerate automatically from other parts of the Corresponding
|
137 |
+
Source.
|
138 |
+
|
139 |
+
The Corresponding Source for a work in source code form is that
|
140 |
+
same work.
|
141 |
+
|
142 |
+
2. Basic Permissions.
|
143 |
+
|
144 |
+
All rights granted under this License are granted for the term of
|
145 |
+
copyright on the Program, and are irrevocable provided the stated
|
146 |
+
conditions are met. This License explicitly affirms your unlimited
|
147 |
+
permission to run the unmodified Program. The output from running a
|
148 |
+
covered work is covered by this License only if the output, given its
|
149 |
+
content, constitutes a covered work. This License acknowledges your
|
150 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
151 |
+
|
152 |
+
You may make, run and propagate covered works that you do not
|
153 |
+
convey, without conditions so long as your license otherwise remains
|
154 |
+
in force. You may convey covered works to others for the sole purpose
|
155 |
+
of having them make modifications exclusively for you, or provide you
|
156 |
+
with facilities for running those works, provided that you comply with
|
157 |
+
the terms of this License in conveying all material for which you do
|
158 |
+
not control copyright. Those thus making or running the covered works
|
159 |
+
for you must do so exclusively on your behalf, under your direction
|
160 |
+
and control, on terms that prohibit them from making any copies of
|
161 |
+
your copyrighted material outside their relationship with you.
|
162 |
+
|
163 |
+
Conveying under any other circumstances is permitted solely under
|
164 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
165 |
+
makes it unnecessary.
|
166 |
+
|
167 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
168 |
+
|
169 |
+
No covered work shall be deemed part of an effective technological
|
170 |
+
measure under any applicable law fulfilling obligations under article
|
171 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
172 |
+
similar laws prohibiting or restricting circumvention of such
|
173 |
+
measures.
|
174 |
+
|
175 |
+
When you convey a covered work, you waive any legal power to forbid
|
176 |
+
circumvention of technological measures to the extent such circumvention
|
177 |
+
is effected by exercising rights under this License with respect to
|
178 |
+
the covered work, and you disclaim any intention to limit operation or
|
179 |
+
modification of the work as a means of enforcing, against the work's
|
180 |
+
users, your or third parties' legal rights to forbid circumvention of
|
181 |
+
technological measures.
|
182 |
+
|
183 |
+
4. Conveying Verbatim Copies.
|
184 |
+
|
185 |
+
You may convey verbatim copies of the Program's source code as you
|
186 |
+
receive it, in any medium, provided that you conspicuously and
|
187 |
+
appropriately publish on each copy an appropriate copyright notice;
|
188 |
+
keep intact all notices stating that this License and any
|
189 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
190 |
+
keep intact all notices of the absence of any warranty; and give all
|
191 |
+
recipients a copy of this License along with the Program.
|
192 |
+
|
193 |
+
You may charge any price or no price for each copy that you convey,
|
194 |
+
and you may offer support or warranty protection for a fee.
|
195 |
+
|
196 |
+
5. Conveying Modified Source Versions.
|
197 |
+
|
198 |
+
You may convey a work based on the Program, or the modifications to
|
199 |
+
produce it from the Program, in the form of source code under the
|
200 |
+
terms of section 4, provided that you also meet all of these conditions:
|
201 |
+
|
202 |
+
a) The work must carry prominent notices stating that you modified
|
203 |
+
it, and giving a relevant date.
|
204 |
+
|
205 |
+
b) The work must carry prominent notices stating that it is
|
206 |
+
released under this License and any conditions added under section
|
207 |
+
7. This requirement modifies the requirement in section 4 to
|
208 |
+
"keep intact all notices".
|
209 |
+
|
210 |
+
c) You must license the entire work, as a whole, under this
|
211 |
+
License to anyone who comes into possession of a copy. This
|
212 |
+
License will therefore apply, along with any applicable section 7
|
213 |
+
additional terms, to the whole of the work, and all its parts,
|
214 |
+
regardless of how they are packaged. This License gives no
|
215 |
+
permission to license the work in any other way, but it does not
|
216 |
+
invalidate such permission if you have separately received it.
|
217 |
+
|
218 |
+
d) If the work has interactive user interfaces, each must display
|
219 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
220 |
+
interfaces that do not display Appropriate Legal Notices, your
|
221 |
+
work need not make them do so.
|
222 |
+
|
223 |
+
A compilation of a covered work with other separate and independent
|
224 |
+
works, which are not by their nature extensions of the covered work,
|
225 |
+
and which are not combined with it such as to form a larger program,
|
226 |
+
in or on a volume of a storage or distribution medium, is called an
|
227 |
+
"aggregate" if the compilation and its resulting copyright are not
|
228 |
+
used to limit the access or legal rights of the compilation's users
|
229 |
+
beyond what the individual works permit. Inclusion of a covered work
|
230 |
+
in an aggregate does not cause this License to apply to the other
|
231 |
+
parts of the aggregate.
|
232 |
+
|
233 |
+
6. Conveying Non-Source Forms.
|
234 |
+
|
235 |
+
You may convey a covered work in object code form under the terms
|
236 |
+
of sections 4 and 5, provided that you also convey the
|
237 |
+
machine-readable Corresponding Source under the terms of this License,
|
238 |
+
in one of these ways:
|
239 |
+
|
240 |
+
a) Convey the object code in, or embodied in, a physical product
|
241 |
+
(including a physical distribution medium), accompanied by the
|
242 |
+
Corresponding Source fixed on a durable physical medium
|
243 |
+
customarily used for software interchange.
|
244 |
+
|
245 |
+
b) Convey the object code in, or embodied in, a physical product
|
246 |
+
(including a physical distribution medium), accompanied by a
|
247 |
+
written offer, valid for at least three years and valid for as
|
248 |
+
long as you offer spare parts or customer support for that product
|
249 |
+
model, to give anyone who possesses the object code either (1) a
|
250 |
+
copy of the Corresponding Source for all the software in the
|
251 |
+
product that is covered by this License, on a durable physical
|
252 |
+
medium customarily used for software interchange, for a price no
|
253 |
+
more than your reasonable cost of physically performing this
|
254 |
+
conveying of source, or (2) access to copy the
|
255 |
+
Corresponding Source from a network server at no charge.
|
256 |
+
|
257 |
+
c) Convey individual copies of the object code with a copy of the
|
258 |
+
written offer to provide the Corresponding Source. This
|
259 |
+
alternative is allowed only occasionally and noncommercially, and
|
260 |
+
only if you received the object code with such an offer, in accord
|
261 |
+
with subsection 6b.
|
262 |
+
|
263 |
+
d) Convey the object code by offering access from a designated
|
264 |
+
place (gratis or for a charge), and offer equivalent access to the
|
265 |
+
Corresponding Source in the same way through the same place at no
|
266 |
+
further charge. You need not require recipients to copy the
|
267 |
+
Corresponding Source along with the object code. If the place to
|
268 |
+
copy the object code is a network server, the Corresponding Source
|
269 |
+
may be on a different server (operated by you or a third party)
|
270 |
+
that supports equivalent copying facilities, provided you maintain
|
271 |
+
clear directions next to the object code saying where to find the
|
272 |
+
Corresponding Source. Regardless of what server hosts the
|
273 |
+
Corresponding Source, you remain obligated to ensure that it is
|
274 |
+
available for as long as needed to satisfy these requirements.
|
275 |
+
|
276 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
277 |
+
you inform other peers where the object code and Corresponding
|
278 |
+
Source of the work are being offered to the general public at no
|
279 |
+
charge under subsection 6d.
|
280 |
+
|
281 |
+
A separable portion of the object code, whose source code is excluded
|
282 |
+
from the Corresponding Source as a System Library, need not be
|
283 |
+
included in conveying the object code work.
|
284 |
+
|
285 |
+
A "User Product" is either (1) a "consumer product", which means any
|
286 |
+
tangible personal property which is normally used for personal, family,
|
287 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
288 |
+
into a dwelling. In determining whether a product is a consumer product,
|
289 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
290 |
+
product received by a particular user, "normally used" refers to a
|
291 |
+
typical or common use of that class of product, regardless of the status
|
292 |
+
of the particular user or of the way in which the particular user
|
293 |
+
actually uses, or expects or is expected to use, the product. A product
|
294 |
+
is a consumer product regardless of whether the product has substantial
|
295 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
296 |
+
the only significant mode of use of the product.
|
297 |
+
|
298 |
+
"Installation Information" for a User Product means any methods,
|
299 |
+
procedures, authorization keys, or other information required to install
|
300 |
+
and execute modified versions of a covered work in that User Product from
|
301 |
+
a modified version of its Corresponding Source. The information must
|
302 |
+
suffice to ensure that the continued functioning of the modified object
|
303 |
+
code is in no case prevented or interfered with solely because
|
304 |
+
modification has been made.
|
305 |
+
|
306 |
+
If you convey an object code work under this section in, or with, or
|
307 |
+
specifically for use in, a User Product, and the conveying occurs as
|
308 |
+
part of a transaction in which the right of possession and use of the
|
309 |
+
User Product is transferred to the recipient in perpetuity or for a
|
310 |
+
fixed term (regardless of how the transaction is characterized), the
|
311 |
+
Corresponding Source conveyed under this section must be accompanied
|
312 |
+
by the Installation Information. But this requirement does not apply
|
313 |
+
if neither you nor any third party retains the ability to install
|
314 |
+
modified object code on the User Product (for example, the work has
|
315 |
+
been installed in ROM).
|
316 |
+
|
317 |
+
The requirement to provide Installation Information does not include a
|
318 |
+
requirement to continue to provide support service, warranty, or updates
|
319 |
+
for a work that has been modified or installed by the recipient, or for
|
320 |
+
the User Product in which it has been modified or installed. Access to a
|
321 |
+
network may be denied when the modification itself materially and
|
322 |
+
adversely affects the operation of the network or violates the rules and
|
323 |
+
protocols for communication across the network.
|
324 |
+
|
325 |
+
Corresponding Source conveyed, and Installation Information provided,
|
326 |
+
in accord with this section must be in a format that is publicly
|
327 |
+
documented (and with an implementation available to the public in
|
328 |
+
source code form), and must require no special password or key for
|
329 |
+
unpacking, reading or copying.
|
330 |
+
|
331 |
+
7. Additional Terms.
|
332 |
+
|
333 |
+
"Additional permissions" are terms that supplement the terms of this
|
334 |
+
License by making exceptions from one or more of its conditions.
|
335 |
+
Additional permissions that are applicable to the entire Program shall
|
336 |
+
be treated as though they were included in this License, to the extent
|
337 |
+
that they are valid under applicable law. If additional permissions
|
338 |
+
apply only to part of the Program, that part may be used separately
|
339 |
+
under those permissions, but the entire Program remains governed by
|
340 |
+
this License without regard to the additional permissions.
|
341 |
+
|
342 |
+
When you convey a copy of a covered work, you may at your option
|
343 |
+
remove any additional permissions from that copy, or from any part of
|
344 |
+
it. (Additional permissions may be written to require their own
|
345 |
+
removal in certain cases when you modify the work.) You may place
|
346 |
+
additional permissions on material, added by you to a covered work,
|
347 |
+
for which you have or can give appropriate copyright permission.
|
348 |
+
|
349 |
+
Notwithstanding any other provision of this License, for material you
|
350 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
351 |
+
that material) supplement the terms of this License with terms:
|
352 |
+
|
353 |
+
a) Disclaiming warranty or limiting liability differently from the
|
354 |
+
terms of sections 15 and 16 of this License; or
|
355 |
+
|
356 |
+
b) Requiring preservation of specified reasonable legal notices or
|
357 |
+
author attributions in that material or in the Appropriate Legal
|
358 |
+
Notices displayed by works containing it; or
|
359 |
+
|
360 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
361 |
+
requiring that modified versions of such material be marked in
|
362 |
+
reasonable ways as different from the original version; or
|
363 |
+
|
364 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
365 |
+
authors of the material; or
|
366 |
+
|
367 |
+
e) Declining to grant rights under trademark law for use of some
|
368 |
+
trade names, trademarks, or service marks; or
|
369 |
+
|
370 |
+
f) Requiring indemnification of licensors and authors of that
|
371 |
+
material by anyone who conveys the material (or modified versions of
|
372 |
+
it) with contractual assumptions of liability to the recipient, for
|
373 |
+
any liability that these contractual assumptions directly impose on
|
374 |
+
those licensors and authors.
|
375 |
+
|
376 |
+
All other non-permissive additional terms are considered "further
|
377 |
+
restrictions" within the meaning of section 10. If the Program as you
|
378 |
+
received it, or any part of it, contains a notice stating that it is
|
379 |
+
governed by this License along with a term that is a further
|
380 |
+
restriction, you may remove that term. If a license document contains
|
381 |
+
a further restriction but permits relicensing or conveying under this
|
382 |
+
License, you may add to a covered work material governed by the terms
|
383 |
+
of that license document, provided that the further restriction does
|
384 |
+
not survive such relicensing or conveying.
|
385 |
+
|
386 |
+
If you add terms to a covered work in accord with this section, you
|
387 |
+
must place, in the relevant source files, a statement of the
|
388 |
+
additional terms that apply to those files, or a notice indicating
|
389 |
+
where to find the applicable terms.
|
390 |
+
|
391 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
392 |
+
form of a separately written license, or stated as exceptions;
|
393 |
+
the above requirements apply either way.
|
394 |
+
|
395 |
+
8. Termination.
|
396 |
+
|
397 |
+
You may not propagate or modify a covered work except as expressly
|
398 |
+
provided under this License. Any attempt otherwise to propagate or
|
399 |
+
modify it is void, and will automatically terminate your rights under
|
400 |
+
this License (including any patent licenses granted under the third
|
401 |
+
paragraph of section 11).
|
402 |
+
|
403 |
+
However, if you cease all violation of this License, then your
|
404 |
+
license from a particular copyright holder is reinstated (a)
|
405 |
+
provisionally, unless and until the copyright holder explicitly and
|
406 |
+
finally terminates your license, and (b) permanently, if the copyright
|
407 |
+
holder fails to notify you of the violation by some reasonable means
|
408 |
+
prior to 60 days after the cessation.
|
409 |
+
|
410 |
+
Moreover, your license from a particular copyright holder is
|
411 |
+
reinstated permanently if the copyright holder notifies you of the
|
412 |
+
violation by some reasonable means, this is the first time you have
|
413 |
+
received notice of violation of this License (for any work) from that
|
414 |
+
copyright holder, and you cure the violation prior to 30 days after
|
415 |
+
your receipt of the notice.
|
416 |
+
|
417 |
+
Termination of your rights under this section does not terminate the
|
418 |
+
licenses of parties who have received copies or rights from you under
|
419 |
+
this License. If your rights have been terminated and not permanently
|
420 |
+
reinstated, you do not qualify to receive new licenses for the same
|
421 |
+
material under section 10.
|
422 |
+
|
423 |
+
9. Acceptance Not Required for Having Copies.
|
424 |
+
|
425 |
+
You are not required to accept this License in order to receive or
|
426 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
427 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
428 |
+
to receive a copy likewise does not require acceptance. However,
|
429 |
+
nothing other than this License grants you permission to propagate or
|
430 |
+
modify any covered work. These actions infringe copyright if you do
|
431 |
+
not accept this License. Therefore, by modifying or propagating a
|
432 |
+
covered work, you indicate your acceptance of this License to do so.
|
433 |
+
|
434 |
+
10. Automatic Licensing of Downstream Recipients.
|
435 |
+
|
436 |
+
Each time you convey a covered work, the recipient automatically
|
437 |
+
receives a license from the original licensors, to run, modify and
|
438 |
+
propagate that work, subject to this License. You are not responsible
|
439 |
+
for enforcing compliance by third parties with this License.
|
440 |
+
|
441 |
+
An "entity transaction" is a transaction transferring control of an
|
442 |
+
organization, or substantially all assets of one, or subdividing an
|
443 |
+
organization, or merging organizations. If propagation of a covered
|
444 |
+
work results from an entity transaction, each party to that
|
445 |
+
transaction who receives a copy of the work also receives whatever
|
446 |
+
licenses to the work the party's predecessor in interest had or could
|
447 |
+
give under the previous paragraph, plus a right to possession of the
|
448 |
+
Corresponding Source of the work from the predecessor in interest, if
|
449 |
+
the predecessor has it or can get it with reasonable efforts.
|
450 |
+
|
451 |
+
You may not impose any further restrictions on the exercise of the
|
452 |
+
rights granted or affirmed under this License. For example, you may
|
453 |
+
not impose a license fee, royalty, or other charge for exercise of
|
454 |
+
rights granted under this License, and you may not initiate litigation
|
455 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
456 |
+
any patent claim is infringed by making, using, selling, offering for
|
457 |
+
sale, or importing the Program or any portion of it.
|
458 |
+
|
459 |
+
11. Patents.
|
460 |
+
|
461 |
+
A "contributor" is a copyright holder who authorizes use under this
|
462 |
+
License of the Program or a work on which the Program is based. The
|
463 |
+
work thus licensed is called the contributor's "contributor version".
|
464 |
+
|
465 |
+
A contributor's "essential patent claims" are all patent claims
|
466 |
+
owned or controlled by the contributor, whether already acquired or
|
467 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
468 |
+
by this License, of making, using, or selling its contributor version,
|
469 |
+
but do not include claims that would be infringed only as a
|
470 |
+
consequence of further modification of the contributor version. For
|
471 |
+
purposes of this definition, "control" includes the right to grant
|
472 |
+
patent sublicenses in a manner consistent with the requirements of
|
473 |
+
this License.
|
474 |
+
|
475 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
476 |
+
patent license under the contributor's essential patent claims, to
|
477 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
478 |
+
propagate the contents of its contributor version.
|
479 |
+
|
480 |
+
In the following three paragraphs, a "patent license" is any express
|
481 |
+
agreement or commitment, however denominated, not to enforce a patent
|
482 |
+
(such as an express permission to practice a patent or covenant not to
|
483 |
+
sue for patent infringement). To "grant" such a patent license to a
|
484 |
+
party means to make such an agreement or commitment not to enforce a
|
485 |
+
patent against the party.
|
486 |
+
|
487 |
+
If you convey a covered work, knowingly relying on a patent license,
|
488 |
+
and the Corresponding Source of the work is not available for anyone
|
489 |
+
to copy, free of charge and under the terms of this License, through a
|
490 |
+
publicly available network server or other readily accessible means,
|
491 |
+
then you must either (1) cause the Corresponding Source to be so
|
492 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
493 |
+
patent license for this particular work, or (3) arrange, in a manner
|
494 |
+
consistent with the requirements of this License, to extend the patent
|
495 |
+
license to downstream recipients. "Knowingly relying" means you have
|
496 |
+
actual knowledge that, but for the patent license, your conveying the
|
497 |
+
covered work in a country, or your recipient's use of the covered work
|
498 |
+
in a country, would infringe one or more identifiable patents in that
|
499 |
+
country that you have reason to believe are valid.
|
500 |
+
|
501 |
+
If, pursuant to or in connection with a single transaction or
|
502 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
503 |
+
covered work, and grant a patent license to some of the parties
|
504 |
+
receiving the covered work authorizing them to use, propagate, modify
|
505 |
+
or convey a specific copy of the covered work, then the patent license
|
506 |
+
you grant is automatically extended to all recipients of the covered
|
507 |
+
work and works based on it.
|
508 |
+
|
509 |
+
A patent license is "discriminatory" if it does not include within
|
510 |
+
the scope of its coverage, prohibits the exercise of, or is
|
511 |
+
conditioned on the non-exercise of one or more of the rights that are
|
512 |
+
specifically granted under this License. You may not convey a covered
|
513 |
+
work if you are a party to an arrangement with a third party that is
|
514 |
+
in the business of distributing software, under which you make payment
|
515 |
+
to the third party based on the extent of your activity of conveying
|
516 |
+
the work, and under which the third party grants, to any of the
|
517 |
+
parties who would receive the covered work from you, a discriminatory
|
518 |
+
patent license (a) in connection with copies of the covered work
|
519 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
520 |
+
for and in connection with specific products or compilations that
|
521 |
+
contain the covered work, unless you entered into that arrangement,
|
522 |
+
or that patent license was granted, prior to 28 March 2007.
|
523 |
+
|
524 |
+
Nothing in this License shall be construed as excluding or limiting
|
525 |
+
any implied license or other defenses to infringement that may
|
526 |
+
otherwise be available to you under applicable patent law.
|
527 |
+
|
528 |
+
12. No Surrender of Others' Freedom.
|
529 |
+
|
530 |
+
If conditions are imposed on you (whether by court order, agreement or
|
531 |
+
otherwise) that contradict the conditions of this License, they do not
|
532 |
+
excuse you from the conditions of this License. If you cannot convey a
|
533 |
+
covered work so as to satisfy simultaneously your obligations under this
|
534 |
+
License and any other pertinent obligations, then as a consequence you may
|
535 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
536 |
+
to collect a royalty for further conveying from those to whom you convey
|
537 |
+
the Program, the only way you could satisfy both those terms and this
|
538 |
+
License would be to refrain entirely from conveying the Program.
|
539 |
+
|
540 |
+
13. Remote Network Interaction; Use with the GNU General Public License.
|
541 |
+
|
542 |
+
Notwithstanding any other provision of this License, if you modify the
|
543 |
+
Program, your modified version must prominently offer all users
|
544 |
+
interacting with it remotely through a computer network (if your version
|
545 |
+
supports such interaction) an opportunity to receive the Corresponding
|
546 |
+
Source of your version by providing access to the Corresponding Source
|
547 |
+
from a network server at no charge, through some standard or customary
|
548 |
+
means of facilitating copying of software. This Corresponding Source
|
549 |
+
shall include the Corresponding Source for any work covered by version 3
|
550 |
+
of the GNU General Public License that is incorporated pursuant to the
|
551 |
+
following paragraph.
|
552 |
+
|
553 |
+
Notwithstanding any other provision of this License, you have
|
554 |
+
permission to link or combine any covered work with a work licensed
|
555 |
+
under version 3 of the GNU General Public License into a single
|
556 |
+
combined work, and to convey the resulting work. The terms of this
|
557 |
+
License will continue to apply to the part which is the covered work,
|
558 |
+
but the work with which it is combined will remain governed by version
|
559 |
+
3 of the GNU General Public License.
|
560 |
+
|
561 |
+
14. Revised Versions of this License.
|
562 |
+
|
563 |
+
The Free Software Foundation may publish revised and/or new versions of
|
564 |
+
the GNU Affero General Public License from time to time. Such new versions
|
565 |
+
will be similar in spirit to the present version, but may differ in detail to
|
566 |
+
address new problems or concerns.
|
567 |
+
|
568 |
+
Each version is given a distinguishing version number. If the
|
569 |
+
Program specifies that a certain numbered version of the GNU Affero General
|
570 |
+
Public License "or any later version" applies to it, you have the
|
571 |
+
option of following the terms and conditions either of that numbered
|
572 |
+
version or of any later version published by the Free Software
|
573 |
+
Foundation. If the Program does not specify a version number of the
|
574 |
+
GNU Affero General Public License, you may choose any version ever published
|
575 |
+
by the Free Software Foundation.
|
576 |
+
|
577 |
+
If the Program specifies that a proxy can decide which future
|
578 |
+
versions of the GNU Affero General Public License can be used, that proxy's
|
579 |
+
public statement of acceptance of a version permanently authorizes you
|
580 |
+
to choose that version for the Program.
|
581 |
+
|
582 |
+
Later license versions may give you additional or different
|
583 |
+
permissions. However, no additional obligations are imposed on any
|
584 |
+
author or copyright holder as a result of your choosing to follow a
|
585 |
+
later version.
|
586 |
+
|
587 |
+
15. Disclaimer of Warranty.
|
588 |
+
|
589 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
590 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
591 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
592 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
593 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
594 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
595 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
596 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
597 |
+
|
598 |
+
16. Limitation of Liability.
|
599 |
+
|
600 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
601 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
602 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
603 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
604 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
605 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
606 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
607 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
608 |
+
SUCH DAMAGES.
|
609 |
+
|
610 |
+
17. Interpretation of Sections 15 and 16.
|
611 |
+
|
612 |
+
If the disclaimer of warranty and limitation of liability provided
|
613 |
+
above cannot be given local legal effect according to their terms,
|
614 |
+
reviewing courts shall apply local law that most closely approximates
|
615 |
+
an absolute waiver of all civil liability in connection with the
|
616 |
+
Program, unless a warranty or assumption of liability accompanies a
|
617 |
+
copy of the Program in return for a fee.
|
618 |
+
|
619 |
+
END OF TERMS AND CONDITIONS
|
README.md
CHANGED
@@ -1,12 +1,186 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## This project is no longer maintained. Visit [this repo](https://github.com/TeamPiped/Piped) for an alternative.
|
2 |
+
|
3 |
+
<p align="center"> <img width="700" src="app/static/img/banner.png"> </img></p>
|
4 |
+
<p align="center">
|
5 |
+
<a href="https://www.gnu.org/licenses/gpl-3.0"><img alt="License: GPL v3" src="https://img.shields.io/badge/License-AGPLv3-blue.svg"></img></a>
|
6 |
+
<a href="https://github.com/pluja/Yotter"><img alt="Development state" src="https://img.shields.io/badge/State-Beta-blue.svg"></img></a>
|
7 |
+
<a href="https://github.com/pluja/Yotter/pulls"><img alt="Pull Requests Welcome" src="https://img.shields.io/badge/PRs-Welcome-green.svg"></img></a>
|
8 |
+
<a href="https://git.kavin.rocks/kavin/Yotter"><img alt="Mirror 1" src="https://img.shields.io/badge/Mirror1-git.kavin.rocks-teal"></img></a>
|
9 |
+
<a href="https://84.38.177.154/libremirrors/ytorg/Yotter"><img alt="Mirror 2" src="https://img.shields.io/badge/Mirror2-git.rip-purple"></img></a>
|
10 |
+
</p>
|
11 |
+
|
12 |
+
Yotter allows you to follow and gather all the content from your favorite Twitter and YouTube accounts in a *beautiful* feed so you can stay up to date without compromising your privacy at all. Yotter is written with Python and Flask and uses Semantic-UI as its CSS framework.
|
13 |
+
|
14 |
+
Yotter is possible thanks to several open-source projects that are listed on the [Powered by](#powered-by) section. Make sure to check out those awesome projects!
|
15 |
+
|
16 |
+
# Index:
|
17 |
+
* [Why](#why)
|
18 |
+
* [Features](#features)
|
19 |
+
* [Roadmap](#roadmap)
|
20 |
+
* [FAQ](#FAQ)
|
21 |
+
* [Privacy and Security](#privacy)
|
22 |
+
* [Public instances](#public-instances)
|
23 |
+
* [Self hosting](https://github.com/ytorg/Yotter/blob/dev-indep/SELF-HOSTING.md)
|
24 |
+
* [Contributing and contact](#contributing)
|
25 |
+
* [Powered by](#powered-by)
|
26 |
+
* [Donate](#donate)
|
27 |
+
* [Screenshots](#screenshots)
|
28 |
+
* [Redirect Extensions](#redirect)
|
29 |
+
|
30 |
+
# Why
|
31 |
+
Youtube and Twitter are well-known by their invasive and data-stealing *'privacy policies'*. You give them a **lot** of data; from ideology to music taste, your likes and dislikes, your free-time schedule, and much more than you think. This much data gives such companies a control over you that you would never thought.
|
32 |
+
|
33 |
+
With the *particular* data about you, they can get money from the highest bidder and target advertisements. This could seem *not-as-bad* but it gets worse. They can sell this data to some company that, with such knowledge about you, could harm your future in a way you can't imagine. What if you are watching self-help videos on Youtube and this data ends on you insurance hands? Would they raise your fee because they consider you are not *emotionally stable*? We can think of thousands of examples like this, where the data ends in the wrong hands and harms you in an unexpected way.
|
34 |
+
|
35 |
+
Further more, they don't care about **what you in particular watch**, this is only sold to the highest bidder who then may or may not do the harm. What they care more about is **what people watch** this is the important data and the one that allows to manipulate, bias, censor, etc.
|
36 |
+
|
37 |
+
So we need platforms and spaces where we can freely watch and listen content without these watchful eyes upon us. Ideally, everyone would use a free (as in freedom) and decentralized platform like [Peertube](https://joinpeertube.org/), [Odysee](https://odysee.com/), [Mastodon](https://joinmastodon.org/) or [Pleroma](https://pleroma.social/) but things are not like this. The main multimedia content factory is Youtube and the microblogging king is Twitter. So we will do whatever is possible to be able to watch and read the content and avoid the surveillance that seeks us these days. We will resist.
|
38 |
+
|
39 |
+
# Features:
|
40 |
+
- [x] No Ads.
|
41 |
+
- [x] No Javascript needed*
|
42 |
+
- [x] Minimalist.
|
43 |
+
- [x] Search on Twitter and Youtube.
|
44 |
+
- [x] Zero connections to Google/Twitter on the client.
|
45 |
+
- [x] Follow Twitter accounts.
|
46 |
+
- [x] Follow Youtube accounts.
|
47 |
+
- [x] Play Youtube videos on background on Android.
|
48 |
+
- [x] Play only audio from youtube to save data.
|
49 |
+
- [x] Save your favourite Tweets.
|
50 |
+
- [x] Tor-friendly.
|
51 |
+
- [x] Terminal-browser friendly.
|
52 |
+
- [x] Fair non-adictive UX - No recommendations, no trending, no tops. Just your feed and your searches.
|
53 |
+
|
54 |
+
*Video player is VideoJS, which uses JavaScript. But if JavaScript is disabled Yotter still works perfectly and uses the default HTML video player.
|
55 |
+
|
56 |
+
### Roadmap
|
57 |
+
The following features are planned to be implemented in the near future:
|
58 |
+
* [ ] Improve performance and efficiency
|
59 |
+
|
60 |
+
#### Youtube specific:
|
61 |
+
* [ ] Subtitles
|
62 |
+
* [ ] > 720p Quality
|
63 |
+
* [ ] Save youtube videos
|
64 |
+
* [ ] Support for live streams
|
65 |
+
|
66 |
+
#### Twitter specific:
|
67 |
+
* [ ] Translations
|
68 |
+
|
69 |
+
# FAQ
|
70 |
+
### What's the difference between this and Invidious?
|
71 |
+
At first I started working on this project as a solution for following Twitter accounts (a thing that can't be done with Nitter) and getting a Twitter-like feed. Weeks later the leader of Invidious, Omar Roth, announced that he was stepping away from the project. As an Invidious active user, this made me think that a new alternative was needed for the community and also an alternative with an easier programming language for most people (as Invidious is written in Crystal). So I started developing a '*written-in-python Invidious alternative*' and it went quite well.
|
72 |
+
|
73 |
+
I hope that this project can prosper, gain contributors, new instances and create a good community around it.
|
74 |
+
|
75 |
+
### Why do I have to register to use Yotter?
|
76 |
+
|
77 |
+
Registering has two main reasons:
|
78 |
+
|
79 |
+
1. Yotter is in a **beta** state. This means that we will be incrementally increasing the capacity of the servers so we can empirically know how many users a Yotter server can handle. Also, there is no **big server** with capacity for handling any arbitrary ammount of users and serving video/data to those at the moment. For this, we decided to have a registration form so we could limit the users.
|
80 |
+
|
81 |
+
2. Yotter allows users to follow accounts and have a custom feed. This needs an account to save your followed users and generate a feed.
|
82 |
+
|
83 |
+
Admins are allowed to remove restrictions on any page they want. [Check this section](https://github.com/ytorg/Yotter/blob/dev-indep/SELF-HOSTING.md#removing-log-in-restrictions) to learn how.
|
84 |
+
|
85 |
+
If you want to use Yotter, it is recommended to self-host your own instance. You can use it for personal use or open it to the world. Self-hosting makes Yotter stronger and gives you full power. See [self hosting guide](https://github.com/ytorg/Yotter/blob/dev-indep/SELF-HOSTING.md).
|
86 |
+
|
87 |
+
### Will you ever implement video recommendations, trending videos, etc?
|
88 |
+
No. From my point of view, these are toxic features. I, and every user, should be using all *social media* to get the content **they** want. Recomendations, trending, autoplay next video, etc. are all features designed to trap users on using the app, to make them forget about the time spent there and to create an addiction to it. No, I won't implement any toxic features on Yotter. Yotter will keep the UI clean, fast and simple.
|
89 |
+
|
90 |
+
You get your feed from followed accounts and you can search for any video you like. Only thing I would consider implementing would be some kind of page where you can ask for recommendations for a particular video. This way the user would, voluntarily, ask for the recommendations rather than having a temptation to click on a new, youtube-bias-recommended video.
|
91 |
+
|
92 |
+
Please read: [1](https://arxiv.org/abs/1912.11211), [2](https://medium.com/dataseries/how-youtube-is-addictive-259d5c575883), [3](https://www.their.tube/), [4](https://www.sciencedirect.com/science/article/pii/S1386505619308743?via%3Dihub)
|
93 |
+
|
94 |
+
# Privacy
|
95 |
+
#### Connections
|
96 |
+
Yotter cares about your privacy, and for this it will never make any connection to Twitter or Youtube on the client. Every request is proxied through the Yotter server; video streaming, photos, data gathering, scrapping, etc.
|
97 |
+
|
98 |
+
The Yotter server connects to Google (Youtube) and Nitter in order to gather all the necessary data. Then it serves it (proxyed through itself) to the client. This means that as a client, you will never connect to Google/Youtube/Twitter - the Yotter server will do it for you. So if you want to set up a Yotter server for privacy reasons I recommend you to set it up on a remote VPS so you don't share your IP with, or use a VPN on the server.
|
99 |
+
|
100 |
+
If you don't mind exposing your IP making requests to Google then you can set it up wherever you want. Even with this method you will **avoid all trackers, ads, heavy-loaded pages, etc**. - you can still stay safe if you use a VPN to hide your IP.
|
101 |
+
|
102 |
+
#### Your data
|
103 |
+
The only things the database stores are:
|
104 |
+
* Salted hash of the password
|
105 |
+
* Username
|
106 |
+
* List of followed users
|
107 |
+
* List of saved posts
|
108 |
+
* Some user configurations
|
109 |
+
|
110 |
+
This data will never be used for any other purpose than offering the service to the user. It's not sent anywhere, never.
|
111 |
+
|
112 |
+
#### Security
|
113 |
+
Only the salted hash of your password is stored in the database, so no admin can see or guess your plain-text password ever. Also, no personal information of any kind is required nor kept, if a hacker gets access to the database the only thing they could do would be to follow/unfollow some accounts. So there's no motivation in 'hacking' Yotter.
|
114 |
+
|
115 |
+
I always recommend self-hosting, as you will be the only person with access to your data.
|
116 |
+
|
117 |
+
> Important note: The **client** never connects to Google / Youtube however, the server does in order to gather all the necessary things!
|
118 |
+
|
119 |
+
# Public Instances
|
120 |
+
| Name |Server location|Status & Register|
|
121 |
+
| ------------ | ------------ | ------------ |
|
122 |
+
| https://yotter.xyz/ |Germany| [Go](https://yotter.xyz/status)|
|
123 |
+
| https://yotter.kavin.rocks/ |India| [Go](https://yotter.kavin.rocks/status)|
|
124 |
+
| https://yotter.jank.media/ |Germany| [Go](https://yotter.jank.media/status)|
|
125 |
+
|
126 |
+
# Contributing
|
127 |
+
Contributors are always welcome. You can help in many ways: Coding, organizing, designing, [donating](#donate), maintaining... You choose what you want to help with!
|
128 |
+
|
129 |
+
We have a [Matrix](https://matrix.org/) room where we discuss anything related with Yotter, feel free to enter the room and start talking or reading. You can choose a Matrix client from [this list of Matrix clients](https://matrix.org/clients/). Also you will need to choose an instance to host your account, you can find Matrix instances [here](https://www.hello-matrix.net/public_servers.php).
|
130 |
+
|
131 |
+
<a href="https://matrix.to/#/!wqJnbUtEfitxtOsLFj:privacytools.io?via=privacytools.io&via=matrix.org"><img alt="Join Matrix" src="https://img.shields.io/badge/Join Room-Matrix-black.svg">
|
132 |
+
|
133 |
+
#### Other platforms:
|
134 |
+
<a href="https://reddit.com/r/Yotter"><img alt="Join Matrix" src="https://img.shields.io/badge/Reddit-r/Yotter-orange.svg">
|
135 |
+
|
136 |
+
# Powered by:
|
137 |
+
These are projects that either make Yotter possible as an **essential part** of it or that served as **inspiration for some parts** of the code.
|
138 |
+
|
139 |
+
* [Nitter](https://nitter.net/)
|
140 |
+
* [Youtube-local](https://github.com/user234683/youtube-local)
|
141 |
+
* [youtube-dlc](https://github.com/blackjack4494/yt-dlc)
|
142 |
+
* [Flask](https://flask.palletsprojects.com/)
|
143 |
+
* [SQLAlchemy](https://docs.sqlalchemy.org/en/13/)
|
144 |
+
* [Semantic-UI](https://semantic-ui.com)
|
145 |
+
* [requests-futures](https://github.com/ross/requests-futures)
|
146 |
+
* [microblog](https://github.com/miguelgrinberg/microblog)
|
147 |
+
* [Video.js](https://videojs.com/)
|
148 |
+
* [Invidious](https://github.com/iv-org/invidious)
|
149 |
+
|
150 |
+
# [Donate](https://github.com/pluja/pluja/blob/main/SUPPORT.md)
|
151 |
+
|
152 |
+
[Click here to see donation options](https://github.com/pluja/pluja/blob/main/SUPPORT.md)
|
153 |
+
|
154 |
+
This project is completely free and Open Source and will always be.
|
155 |
+
|
156 |
+
Donations are used to mantain the [yotter.xyz](https://yotter.xyz/) public instance. [This is the server](https://www.netcup.eu/bestellen/produkt.php?produkt=2598) that I have rented for now.
|
157 |
+
|
158 |
+
## Screenshots
|
159 |
+
#### Twitter / Tweets / Profiles
|
160 |
+
<p align="center"> <img width="720" src="https://i.imgur.com/tA15ciH.png"> </img></p>
|
161 |
+
<p align="center"> <img width="720" src="https://i.imgur.com/BYswFy6.png"> </img></p>
|
162 |
+
|
163 |
+
#### Twitter search
|
164 |
+
<p align="center"> <img width="720" src="https://i.imgur.com/KalBDa5.png"> </img></p>
|
165 |
+
|
166 |
+
#### Youtube feed
|
167 |
+
<p align="center"> <img width="720" src="https://i.imgur.com/rHsKl0e.png"> </img></p>
|
168 |
+
|
169 |
+
#### Youtube video page / Comments
|
170 |
+
<p align="center"> <img width="720" src="https://i.imgur.com/pQhLcvI.png"> </img></p>
|
171 |
+
<p align="center"> <img width="720" src="https://i.imgur.com/kZPGUdq.png"> </img></p>
|
172 |
+
|
173 |
+
#### Youtube channel page
|
174 |
+
<p align="center"> <img width="720" src="https://i.imgur.com/zybRB7X.png"> </img></p>
|
175 |
+
|
176 |
+
#### Youtube search
|
177 |
+
<p align="center"> <img width="720" src="https://i.imgur.com/XHCSNTP.png"> </img></p>
|
178 |
+
|
179 |
+
## Redirect
|
180 |
+
If you want to worry less and enjoy Yotter more, you can use any of the following extensions to redirect Youtube to Yotter automatically:
|
181 |
+
|
182 |
+
* [Youtter](https://addons.mozilla.org/en-US/firefox/addon/youtter/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search) - Firefox
|
183 |
+
* [Privacy Redirect](https://addons.mozilla.org/en-US/firefox/addon/youtter/?utm_source=addons.mozilla.org&utm_medium=referral&utm_content=search) - Chromium
|
184 |
+
* Set Yotter as a Invidious instance on extension options.
|
185 |
+
* [HTTPSEverywhere](https://www.eff.org/https-everywhere) - Both
|
186 |
+
* You can set up redirects. Use a "http://youtube.com/ -> https://yotterinstance.xyz/" redirect.
|
SELF-HOSTING.md
ADDED
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<a href="https://github.com/pluja/Yotter"><img alt="Installation Working" src="https://img.shields.io/badge/Status-Working 2020.10.05-green.svg"></img></a>
|
2 |
+
<a href="https://github.com/pluja/Yotter"><img alt="Tested on Ubuntu" src="https://img.shields.io/badge/Tested On-Ubuntu Server 20.04LTS-blue.svg"></img></a>
|
3 |
+
|
4 |
+
# Why should I self host?
|
5 |
+
Self-hosting gives you the whole power over the service and the data. You can set up a server for your own personal use or share it with friends and family. Or, why not go further and share it with the whole world?
|
6 |
+
|
7 |
+
When you self-host you make internet stronger and more censorship resistant. If one Yotter instance goes down for any reason, there will be all other instances online and ready to host new users.
|
8 |
+
|
9 |
+
# Index
|
10 |
+
* [Pre-Installation](#pre-installation)
|
11 |
+
* [Installation](#installation)
|
12 |
+
* [Docker Installation](#docker)
|
13 |
+
* [Manual Installation](#manual-installation)
|
14 |
+
* [Configure the server](#configure-the-server)
|
15 |
+
* [Update](#updating-the-server)
|
16 |
+
* [Others](#other-configurations)
|
17 |
+
|
18 |
+
|
19 |
+
# First Steps
|
20 |
+
|
21 |
+
You will need a server of your own, it is recomended to rent a VPS server on any service you like. Minimum requirements for ~100 users are 2GB of RAM and a Linux Server. It is better if the server is dedicated as whole to Yotter as it will improve performance and security.
|
22 |
+
|
23 |
+
Everything that appears between `< >` needs to be changed by you. So for example if you see `<password>` you should change it for `yourPassword` without keeping the `< >`.
|
24 |
+
|
25 |
+
## Set up a user
|
26 |
+
First of all, you will need to set up a new user on the server. For security reasons you should **never** use a `root` user to set up a service. If you already have a non-root user you can use that one and skip the following steps.
|
27 |
+
|
28 |
+
We will create a user named `ubuntu` as I will be setting this up on an ubuntu machine. So, if you choose a different username make sure you replace it on future commands. We will create and login to the user as follows:
|
29 |
+
|
30 |
+
```
|
31 |
+
# adduser --gecos "" ubuntu
|
32 |
+
# usermod -aG sudo ubuntu
|
33 |
+
# su ubuntu
|
34 |
+
$ cd
|
35 |
+
```
|
36 |
+
|
37 |
+
If you now type `pwd` and hit enter, you shuould see that the current path is `/home/<user>/`
|
38 |
+
|
39 |
+
Now you should be logged in. Make sure to set up a good password. It is recommended to use ssh keys to log-in remotelly and disable the password login on all users.
|
40 |
+
|
41 |
+
# Installation
|
42 |
+
|
43 |
+
## Docker
|
44 |
+
|
45 |
+
### 1. Pre-Configuration
|
46 |
+
|
47 |
+
1. [Install docker](https://paste.ubuntu.com/p/KMDHqs3XvB/):
|
48 |
+
> Instructions for Ubuntu 20.04LTS. For any other systems there are plenty of guides on the internet.
|
49 |
+
|
50 |
+
2. [Install docker-compose](https://paste.ubuntu.com/p/pgqkPzCpJk/):
|
51 |
+
> General instructions for all Linux systems
|
52 |
+
|
53 |
+
3. You can check it was installed with `docker-compose --version`
|
54 |
+
|
55 |
+
4. Install nginx if not installed.
|
56 |
+
* `sudo apt install nginx`
|
57 |
+
|
58 |
+
### 2. Setting up Yotter
|
59 |
+
|
60 |
+
1. Run the following commands on your server:
|
61 |
+
```
|
62 |
+
git clone https://github.com/ytorg/Yotter && cd Yotter
|
63 |
+
docker-compose up -d
|
64 |
+
chown -R www-data:www-data /var/run/ytproxy
|
65 |
+
```
|
66 |
+
> You may need to use `sudo` for turning up the docker-compose
|
67 |
+
2. Configure nginx as a reverse proxy to your docker container:
|
68 |
+
* Create a new nginx configuration file:
|
69 |
+
- `sudo nano /etc/nginx/sites-enabled/yotter`
|
70 |
+
* Paste the content of [this file](https://paste.ubuntu.com/p/248hh6crWH/) to the config file.
|
71 |
+
- Change `<example.com>` by your domain.
|
72 |
+
* Generate a ssl certificate:
|
73 |
+
- Follow [Let's Encrypt](https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx) guide **(Recommended)**
|
74 |
+
- Only steps `3`, `5`, `6` and `7a (first command only)` are needed.
|
75 |
+
|
76 |
+
* Reload nginx:
|
77 |
+
- `sudo service nginx reload`
|
78 |
+
|
79 |
+
3. You are now ready to use Yotter on your domain!
|
80 |
+
- **Note that you will need to set up your domain DNS to resolve to your server IP.**
|
81 |
+
|
82 |
+
##### Extra step:
|
83 |
+
- [Configure the server](#configure-the-server)
|
84 |
+
|
85 |
+
### How Update with Docker
|
86 |
+
```
|
87 |
+
$ docker-compose down
|
88 |
+
$ docker pull ytorg/yotter
|
89 |
+
$ docker-compose up -d
|
90 |
+
```
|
91 |
+
> `sudo` may be needed.
|
92 |
+
|
93 |
+
<hr>
|
94 |
+
|
95 |
+
## Manual installation
|
96 |
+
|
97 |
+
#### Step 1: Base setup
|
98 |
+
1. Connect to your server via SSH or direct access.
|
99 |
+
- `ssh ubuntu@<ipaddress>`
|
100 |
+
- [x] (Recommended) Set up password-less login with ssh-keys.
|
101 |
+
|
102 |
+
2. Install base dependencies:
|
103 |
+
* `sudo apt-get -y update`
|
104 |
+
|
105 |
+
* `sudo apt-get -y install python3 python3-venv python3-dev`
|
106 |
+
|
107 |
+
* `sudo apt-get -y install mysql-server supervisor nginx git`
|
108 |
+
|
109 |
+
> When installing MySQL-server it will prompt for a root password. This is the password for the root user of MySQL. Set up a password of your like, this will be the MySQL databases master password and will be required later, so don't forget it!
|
110 |
+
|
111 |
+
If after the MySQL-server installation you have not been prompted to create a password for the `root` user, run `sudo mysql_secure_installation`
|
112 |
+
|
113 |
+
3. Clone this repository and acccess folder:
|
114 |
+
* `git clone https://github.com/ytorg/Yotter`
|
115 |
+
|
116 |
+
* `cd Yotter`
|
117 |
+
|
118 |
+
4. Create a Python virtual environment and populate it with dependencies:
|
119 |
+
* `python3 -m venv venv`
|
120 |
+
* `source venv/bin/activate`
|
121 |
+
|
122 |
+
* `pip install wheel`
|
123 |
+
* `pip install cryptography`
|
124 |
+
* `pip install -r requirements.txt`
|
125 |
+
|
126 |
+
> You can edit the `yotter-config.json` file. [Check out all the options here](#configure-the-server)
|
127 |
+
|
128 |
+
5. Install gunicorn (production web server for Python apps) and pymysql:
|
129 |
+
`pip install gunicorn pymysql`
|
130 |
+
|
131 |
+
6. Set up the database tables:
|
132 |
+
* `flask db init`
|
133 |
+
* `flask db migrate`
|
134 |
+
* `flask db upgrade`
|
135 |
+
|
136 |
+
7. Set up `.env`
|
137 |
+
1. (PRE) Generate a **random string** and copy it to clipboard:
|
138 |
+
`python3 -c "import uuid; print(uuid.uuid4().hex)"`
|
139 |
+
|
140 |
+
2. Create a `.env` file on the root folder of the project (`/home/ubuntu/Yotter/.env`):
|
141 |
+
```
|
142 |
+
SECRET_KEY=<RandomString>
|
143 |
+
DATABASE_URL=mysql+pymysql://yotter:<db-password>@localhost:3306/yotter
|
144 |
+
```
|
145 |
+
Make sure you change `<RandomString>` for the previously generated random string. You can paste it as is, without any `"" or ''`. Also change `<db-password>`. `<db-password>` should be different from the password of the database root user (the one you set up on step 1.2). This password will be needed later.
|
146 |
+
|
147 |
+
#### Step 2: Setting up the MySQL Database:
|
148 |
+
* Open the MySQL prompt line (Use the previously set MySQL root password!)
|
149 |
+
`mysql -u root -p`
|
150 |
+
|
151 |
+
> Note that you are being prompted for the password of the MySQL root user, the one you set up on step 1.2, not the password you wrote on the `.env` file. The password on the `.env` is the password for the MySQL Yotter database.
|
152 |
+
|
153 |
+
> If you still have problems with the root user password try running `sudo mysql` and then run this query: `ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<YOUR_PASSWORD>';`. This changes the password for the MySQL user `root` by `<YOUR_PASSWORD>`
|
154 |
+
|
155 |
+
Now you should be on the MySQL prompt line (`mysql>`). So let's create the databases:
|
156 |
+
|
157 |
+
> Change `<db-password>` for a password of your like. It will be the password for the dabase user `yotter`. Don't choose the same password as the root user of MySQL for security.
|
158 |
+
|
159 |
+
> The password `<db-password>` for the **yotter** user needs to match the password that you included in the `DATABASE_URL` variable in the `.env` file. If you want to change it, you can change it now.
|
160 |
+
|
161 |
+
```
|
162 |
+
mysql> create database yotter character set utf8 collate utf8_bin;
|
163 |
+
mysql> create user 'yotter'@'localhost' identified by '<db-password>';
|
164 |
+
mysql> grant all privileges on yotter.* to 'yotter'@'localhost';
|
165 |
+
mysql> flush privileges;
|
166 |
+
mysql> quit;
|
167 |
+
```
|
168 |
+
|
169 |
+
If your set up was correct, you should now be able to run:
|
170 |
+
|
171 |
+
* `flask db upgrade`
|
172 |
+
|
173 |
+
> If you get "No such command" error, run `source env/bin/activate` and try again.
|
174 |
+
|
175 |
+
#### Step 3: Setting up Gunicorn and Supervisor
|
176 |
+
When you run the server with flask run, you are using a web server that comes with Flask. This server is very useful during development, but it isn't a good choice to use for a production server because it wasn't built with performance and robustness in mind. Instead of the Flask development server, for this deployment I decided to use gunicorn, which is also a pure Python web server, but unlike Flask's, it is a robust production server that is used by a lot of people, while at the same time it is very easy to use. [ref](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deployment-on-linux)
|
177 |
+
|
178 |
+
* Start yotter under Gunicorn and check it has no errors:
|
179 |
+
|
180 |
+
`gunicorn -b localhost:8000 -w 4 yotter:app`
|
181 |
+
|
182 |
+
Once you see that no errors appear, you can stop gunicorn by pressing `Ctrl+C`.
|
183 |
+
|
184 |
+
The supervisor utility uses configuration files that tell it what programs to monitor and how to restart them when necessary. Configuration files must be stored in /etc/supervisor/conf.d. Here is a configuration file for Yotter, which I'm going to call yotter.conf [ref](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deployment-on-linux).
|
185 |
+
|
186 |
+
* Create a yotter.conf file on `/etc/supervisor/conf.d/`:
|
187 |
+
|
188 |
+
> You can run `sudo nano /etc/supervisor/conf.d/yotter.conf` and paste the text below:
|
189 |
+
|
190 |
+
> Make sure to fit any path and user to your system.
|
191 |
+
|
192 |
+
```
|
193 |
+
[program:yotter]
|
194 |
+
command=/home/ubuntu/Yotter/venv/bin/gunicorn -b localhost:8000 -w 4 yotter:app
|
195 |
+
directory=/home/ubuntu/Yotter
|
196 |
+
user=ubuntu
|
197 |
+
autostart=true
|
198 |
+
autorestart=true
|
199 |
+
stopasgroup=true
|
200 |
+
killasgroup=true
|
201 |
+
```
|
202 |
+
|
203 |
+
After you write this configuration file, you have to reload the supervisor service for it to be imported:
|
204 |
+
`sudo supervisorctl reload`
|
205 |
+
|
206 |
+
#### Step 4: Set up Nginx, http3 proxy and HTTPS
|
207 |
+
The Yotter application server powered by gunicorn is now running privately port 8000. Now we need to expose the application to the outside world by enabling public facing web server on ports 80 and 443, the two ports too need to be opened on the firewall to handle the web traffic of the application. I want this to be a secure deployment, so I'm going to configure port 80 to forward all traffic to port 443, which is going to be encrypted. [ref](https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xvii-deployment-on-linux).
|
208 |
+
|
209 |
+
First we will get and set up the `http3-ytproxy`. For this we will need to [install go](https://github.com/golang/go/wiki/Ubuntu) but if you are on Ubuntu 20.04 or you have `snap` installed you can just run `sudo snap install --classic go` to get `go` installed.
|
210 |
+
|
211 |
+
Then you will need to run the following commands:
|
212 |
+
```
|
213 |
+
cd $HOME
|
214 |
+
git clone https://github.com/FireMasterK/http3-ytproxy
|
215 |
+
cd http3-ytproxy
|
216 |
+
go build -ldflags "-s -w" main.go
|
217 |
+
mv main http3-ytproxy
|
218 |
+
mkdir socket
|
219 |
+
chown -R www-data:www-data socket
|
220 |
+
```
|
221 |
+
|
222 |
+
Now we will configure a `systemd` service to run the http3-ytproxy. For this you will need to `sudo nano /lib/systemd/system/http3-ytproxy.service` to start a the `nano` text editor. Now copy and paste this and save:
|
223 |
+
|
224 |
+
> IMPORTANT: You may need to change some paths to fit your system!
|
225 |
+
|
226 |
+
```
|
227 |
+
[Unit]
|
228 |
+
Description=Sleep service
|
229 |
+
ConditionPathExists=/home/ubuntu/http3-ytproxy/http3-ytproxy
|
230 |
+
After=network.target
|
231 |
+
|
232 |
+
[Service]
|
233 |
+
Type=simple
|
234 |
+
User=www-data
|
235 |
+
Group=www-data
|
236 |
+
LimitNOFILE=1024
|
237 |
+
|
238 |
+
Restart=on-failure
|
239 |
+
RestartSec=10
|
240 |
+
|
241 |
+
WorkingDirectory=/home/ubuntu/http3-ytproxy
|
242 |
+
ExecStart=/home/ubuntu/http3-ytproxy/http3-ytproxy
|
243 |
+
|
244 |
+
# make sure log directory exists and owned by syslog
|
245 |
+
PermissionsStartOnly=true
|
246 |
+
ExecStartPre=/bin/mkdir -p /var/log/http3-ytproxy
|
247 |
+
ExecStartPre=/bin/chown syslog:adm /var/log/http3-ytproxy
|
248 |
+
ExecStartPre=/bin/chmod 755 /var/log/http3-ytproxy
|
249 |
+
StandardOutput=syslog
|
250 |
+
StandardError=syslog
|
251 |
+
SyslogIdentifier=http3-ytproxy
|
252 |
+
|
253 |
+
[Install]
|
254 |
+
WantedBy=multi-user.target
|
255 |
+
```
|
256 |
+
|
257 |
+
> IMPORTANT NOTE: Some distros have the Nginx user as `nginx` instead of `www-data`, if this is the case you should change the `User=` and `Group=` variables from the service file.
|
258 |
+
|
259 |
+
Now you are ready to enable and start the service:
|
260 |
+
```
|
261 |
+
sudo systemctl enable http3-ytproxy.service
|
262 |
+
sudo systemctl start http3-ytproxy.service
|
263 |
+
```
|
264 |
+
|
265 |
+
If you did everything ok you should see no errors when running `sudo journalctl -f -u http3-ytproxy`.
|
266 |
+
|
267 |
+
Now we will set up Nginx. To do so:
|
268 |
+
|
269 |
+
* `sudo rm /etc/nginx/sites-enabled/default`
|
270 |
+
|
271 |
+
Create a new Nginx site, you can run `sudo nano /etc/nginx/sites-enabled/yotter`
|
272 |
+
|
273 |
+
And write this on it:
|
274 |
+
```
|
275 |
+
server {
|
276 |
+
server_name <yourdomain>;
|
277 |
+
|
278 |
+
location / {
|
279 |
+
proxy_pass http://localhost:8000;
|
280 |
+
}
|
281 |
+
|
282 |
+
location /static {
|
283 |
+
# handle static files directly, without forwarding to the application
|
284 |
+
alias </path/to>/Yotter/app/static;
|
285 |
+
expires 30d;
|
286 |
+
}
|
287 |
+
|
288 |
+
location ~ (^/videoplayback$|/videoplayback/|/vi/|/a/|/ytc/) {
|
289 |
+
proxy_pass http://unix:/home/ubuntu/http3-ytproxy/socket/http-proxy.sock;
|
290 |
+
add_header Access-Control-Allow-Origin *;
|
291 |
+
sendfile on;
|
292 |
+
tcp_nopush on;
|
293 |
+
aio_write on;
|
294 |
+
aio threads=default;
|
295 |
+
directio 512;
|
296 |
+
proxy_http_version 1.1;
|
297 |
+
proxy_set_header Connection "";
|
298 |
+
}
|
299 |
+
}
|
300 |
+
```
|
301 |
+
> Note: You may need to change the proxy-pass line to fit your system. It should point to the socket created on the `http3-ytproxy/socket` folder.
|
302 |
+
|
303 |
+
Make sure to replace `<yourdomain>` by the domain you are willing to use for your instance (i.e example.com). You can now edit `yotter-config.json` and set `isInstance` to `true`.
|
304 |
+
|
305 |
+
You will also need to change the `</path/to>` after `alias` to fit your system. You have to point to the Yotter folder, in this set up it would be `/home/ubuntu` as it is the location where we cloned the Yotter app. This alias is created to handle static files directly, without forwarding to the application.
|
306 |
+
|
307 |
+
Once done, you can run `sudo service nginx reload`. If everything so far went OK, you can now set the `isInstance` to `true` on the `yotter-config.json` file.
|
308 |
+
|
309 |
+
Now you need to install an SSL certificate on your server so you can use HTTPS. If you are running Ubuntu 20LTS or already have `snap` installed, you can proceed as follows:
|
310 |
+
|
311 |
+
1. `sudo snap install --classic certbot`
|
312 |
+
|
313 |
+
> Note that you will have to create an 'A Record' on the DNS of your domain to point to the IP of your server for this next step. If you don't know how to do it, [this guide might help you](https://www.namecheap.com/support/knowledgebase/article.aspx/319/2237/how-can-i-set-up-an-a-address-record-for-my-domain) as on most services the procedure is similar.
|
314 |
+
Now we will run certbot and we need to tell that we run an nginx server. Here you will be prompted which domain you want to create and install the certificate for, select your domain:
|
315 |
+
2. `sudo certbot --nginx`
|
316 |
+
|
317 |
+
|
318 |
+
[Follow this instructions to install certbot and generate an ssl certificate so your server can use HTTPS](https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx)
|
319 |
+
|
320 |
+
Finally, once this is done, you should edit the `yotter` nginx config and change the `listen 443 ssl;` line to `listen 443 ssl http2;`
|
321 |
+
|
322 |
+
#### Updating the server
|
323 |
+
Updating the server should always be pretty easy. These steps need to be run on the Yotter folder and with the python virtual env activated.
|
324 |
+
|
325 |
+
```
|
326 |
+
(venv) $ git pull
|
327 |
+
(venv) $ sudo supervisorctl stop yotter
|
328 |
+
(venv) $ flask db migrate
|
329 |
+
(venv) $ flask db upgrade
|
330 |
+
(venv) $ pip install -r requirements.txt
|
331 |
+
(venv) $ sudo supervisorctl start yotter
|
332 |
+
```
|
333 |
+
* **IMPORTANT**: Make sure you have all set up on `yotter-config.json` once you finish the update.
|
334 |
+
|
335 |
+
<hr>
|
336 |
+
|
337 |
+
## Configure the server
|
338 |
+
You will find in the root folder of the project a file named `yotter-config.json`. This is the global config file for the Yotter server.
|
339 |
+
|
340 |
+
Currently available config is:
|
341 |
+
* **serverName**: Name of the server. Format: `example.com`
|
342 |
+
* **nitterInstance**: Nitter instance that will be used when fetching Twitter content. Format must be `https://<NitterInstance.tld>/`
|
343 |
+
* **maxInstanceUsers**: Max users on the instance. When set to `0` it closes registrations.
|
344 |
+
* **serverLocation**: Location of the server.
|
345 |
+
* **restrictPublicUsage**: When set to `false` the instance allows non-registered users to use some routes (i.e /watch?v=..., /ytsearch, /channel...). See [this section](https://github.com/pluja/Yotter/blob/dev-indep/SELF-HOSTING.md#removing-log-in-restrictions)
|
346 |
+
* **isInstance**: If your installation is on a server using Nginx, it must be True. Only false if running on a local machine. [See this link]()
|
347 |
+
* **maintenance_mode**: Activates a message on the server warning users of maintenance mode.
|
348 |
+
* **show_admin_message**: Shows a message from the admin with title as `admin_message_title` and body as `admin_message`
|
349 |
+
* **admin_user**: Username of the admin user.
|
350 |
+
* **max_old_user_days**: Maximum days for a user to be inactive, otherwise will be deleted if admin uses the action.
|
351 |
+
* **donation_url**: Adds a link to a donation method for the instance.
|
352 |
+
|
353 |
+
## Other configurations
|
354 |
+
|
355 |
+
### Removing log-in restrictions
|
356 |
+
> (NOT TESTED - COULD CRASH THE APP) Note that some routes make usage of the `current_user` variable to look if the current user is following some user or not, if you remove the restriction for such routes the app will crash. This will be solved on future releases.
|
357 |
+
|
358 |
+
For the example, let's allow for anyone to watch a video on our instance. Even if they aren't registered users. First we need to find the route that we want to allow, you can do it by navigating to the page and taking a look at the URL. Anything after the first `/` is the app route. When we're watching a video, the route is `/watch?v=<videoId>`.
|
359 |
+
|
360 |
+
Now on the file `routes.py` we will search for the code that the server runs when we navigate to that route. You can use the Find function on your text editor and search for `/watch`. Now, you will see that right below the definition of the route, `@app.route('/watch')`, there is a `@login_required` line. If you delete that line, no restriction will now be applied to that route.
|
361 |
+
|
362 |
+
But you must know that videos and images are proxied through the instance. So we will need to allow another route. For video streaming, the route is `/stream` and for images it is `/img`. So you just need to delete the `login_required` from those two other routes.
|
363 |
+
|
364 |
+
You can now reload the server and you will see that, without logging in, you can now watch videos.
|
365 |
+
|
366 |
+
|
367 |
+
### Increasing the channel name max size on the database (Only installations older than 2020.09.20)
|
368 |
+
|
369 |
+
On older versions the character limit for a Youtube suscritpion was 30. This caused some problems with channels that had a longer string for the channel name. Since 2020.09.20 version, this problem was solved, but for older installation the problem persists even if you update to the latest github version.
|
370 |
+
|
371 |
+
To solve this, we will need to modify our database and set up new character limits. Don't worry, it's easy.
|
372 |
+
|
373 |
+
First you need to open the MySQL prompt. This can be done wiht `mysql -u root -p`. It will prompt you the **mysql database root user password**, note that it is NOT the *sudo* password. Once you're in the MySQL prompt (`mysql>`) you can execute these commands:
|
374 |
+
|
375 |
+
1. `connect yotter;` - This will connect you to the yotter database.
|
376 |
+
2. `ALTER TABLE channel MODIFY COLUMN channelName VARCHAR(100);` - This alters the field `channelName` from the table `channel` and sets its limit to `100` characters.
|
377 |
+
3. `quit;`
|
app/__init__.py
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import Flask
|
2 |
+
from config import Config
|
3 |
+
from flask_sqlalchemy import SQLAlchemy
|
4 |
+
from flask_migrate import Migrate
|
5 |
+
from flask_login import LoginManager
|
6 |
+
|
7 |
+
app = Flask(__name__)
|
8 |
+
app.config.from_object(Config)
|
9 |
+
db = SQLAlchemy(app)
|
10 |
+
migrate = Migrate(app, db)
|
11 |
+
login = LoginManager(app)
|
12 |
+
login.login_view = 'login'
|
13 |
+
|
14 |
+
from app import routes, models, errors
|
app/cache/.ignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
dummy file for clone and pull.
|
app/errors.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask import render_template
|
2 |
+
from app import app, db
|
3 |
+
|
4 |
+
@app.errorhandler(404)
|
5 |
+
def not_found_error(error):
|
6 |
+
return render_template('404.html'), 404
|
7 |
+
|
8 |
+
@app.errorhandler(500)
|
9 |
+
def internal_error(error):
|
10 |
+
db.session.rollback()
|
11 |
+
return render_template('500.html'), 500
|
12 |
+
|
13 |
+
@app.errorhandler(405)
|
14 |
+
def internal_error(error):
|
15 |
+
db.session.rollback()
|
16 |
+
return render_template('405.html'), 405
|
app/favicon.png
ADDED
![]() |
app/forms.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from flask_wtf import FlaskForm
|
2 |
+
from wtforms import StringField, PasswordField, BooleanField, SubmitField
|
3 |
+
from wtforms.validators import ValidationError, DataRequired, EqualTo
|
4 |
+
from app.models import User
|
5 |
+
|
6 |
+
|
7 |
+
class LoginForm(FlaskForm):
|
8 |
+
style={'class': 'ui primary button'}
|
9 |
+
username = StringField('Username', validators=[DataRequired()])
|
10 |
+
password = PasswordField('Password', validators=[DataRequired()])
|
11 |
+
remember_me = BooleanField('Remember Me')
|
12 |
+
submit = SubmitField('Sign In', render_kw=style)
|
13 |
+
|
14 |
+
class SearchForm(FlaskForm):
|
15 |
+
username = StringField('Username')
|
16 |
+
submit = SubmitField('Search')
|
17 |
+
|
18 |
+
class ChannelForm(FlaskForm):
|
19 |
+
search = StringField('')
|
20 |
+
submit = SubmitField('Search')
|
21 |
+
|
22 |
+
|
23 |
+
class RegistrationForm(FlaskForm):
|
24 |
+
username = StringField('Username', validators=[DataRequired()])
|
25 |
+
password = PasswordField('Password', validators=[DataRequired()])
|
26 |
+
password2 = PasswordField(
|
27 |
+
'Repeat Password', validators=[DataRequired(), EqualTo('password')])
|
28 |
+
submit = SubmitField('Register')
|
29 |
+
|
30 |
+
def validate_username(self, username):
|
31 |
+
user = User.query.filter_by(username=username.data).first()
|
32 |
+
if user is not None:
|
33 |
+
raise ValidationError('Please use a different username.')
|
34 |
+
|
35 |
+
class EmptyForm(FlaskForm):
|
36 |
+
submit = SubmitField('Submit')
|
app/models.py
ADDED
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from datetime import datetime
|
2 |
+
from app import db, login
|
3 |
+
from flask_login import UserMixin
|
4 |
+
from werkzeug.security import generate_password_hash, check_password_hash
|
5 |
+
|
6 |
+
followers = db.Table('followers',
|
7 |
+
db.Column('follower_id', db.Integer, db.ForeignKey('user.id')),
|
8 |
+
db.Column('followed_id', db.Integer, db.ForeignKey('user.id'))
|
9 |
+
)
|
10 |
+
|
11 |
+
channel_association = db.Table('channel_association',
|
12 |
+
db.Column('channel_id', db.Integer, db.ForeignKey('channel.id')),
|
13 |
+
db.Column('user_id', db.Integer, db.ForeignKey('user.id'))
|
14 |
+
) # Association: CHANNEL --followed by--> [USERS]
|
15 |
+
|
16 |
+
twitter_association = db.Table('twitter_association',
|
17 |
+
db.Column('account_id', db.Integer, db.ForeignKey('twitterAccount.id')),
|
18 |
+
db.Column('user_id', db.Integer, db.ForeignKey('user.id'))
|
19 |
+
) # Association: ACCOUNT --followed by--> [USERS]
|
20 |
+
|
21 |
+
class User(UserMixin, db.Model):
|
22 |
+
id = db.Column(db.Integer, primary_key=True)
|
23 |
+
username = db.Column(db.String(64), index=True, unique=True)
|
24 |
+
password_hash = db.Column(db.String(128))
|
25 |
+
last_seen = db.Column(db.DateTime, default=datetime.utcnow())
|
26 |
+
is_admin = db.Column(db.Boolean, default=False, nullable=True)
|
27 |
+
posts = db.relationship('Post', backref='author', lazy='dynamic')
|
28 |
+
|
29 |
+
def __repr__(self):
|
30 |
+
return f'<User {self.username}>'
|
31 |
+
|
32 |
+
def set_last_seen(self):
|
33 |
+
self.last_seen = datetime.utcnow()
|
34 |
+
|
35 |
+
def set_admin_user(self):
|
36 |
+
self.is_admin = True
|
37 |
+
|
38 |
+
def set_password(self, password):
|
39 |
+
self.password_hash = generate_password_hash(password)
|
40 |
+
|
41 |
+
def check_password(self, password):
|
42 |
+
return check_password_hash(self.password_hash, password)
|
43 |
+
|
44 |
+
def follow(self, user):
|
45 |
+
if not self.is_following(user):
|
46 |
+
self.followed.append(user)
|
47 |
+
|
48 |
+
def unfollow(self, user):
|
49 |
+
if self.is_following(user):
|
50 |
+
self.followed.remove(user)
|
51 |
+
|
52 |
+
def is_following(self, user):
|
53 |
+
return self.followed.filter(
|
54 |
+
followers.c.followed_id == user.id).count() > 0
|
55 |
+
|
56 |
+
def following_list(self):
|
57 |
+
return self.followed.all()
|
58 |
+
|
59 |
+
def saved_posts(self):
|
60 |
+
return Post.query.filter_by(user_id=self.id)
|
61 |
+
|
62 |
+
# TWITTER
|
63 |
+
def twitter_following_list(self):
|
64 |
+
return self.twitterFollowed.all()
|
65 |
+
|
66 |
+
def is_following_tw(self, uname):
|
67 |
+
temp_cid = twitterFollow.query.filter_by(username = uname).first()
|
68 |
+
if temp_cid is None:
|
69 |
+
return False
|
70 |
+
else:
|
71 |
+
following = self.twitter_following_list()
|
72 |
+
for f in following:
|
73 |
+
if f.username == uname:
|
74 |
+
return True
|
75 |
+
return False
|
76 |
+
|
77 |
+
# YOUTUBE
|
78 |
+
def youtube_following_list(self):
|
79 |
+
return self.youtubeFollowed.all()
|
80 |
+
|
81 |
+
def is_following_yt(self, cid):
|
82 |
+
temp_cid = youtubeFollow.query.filter_by(channelId = cid).first()
|
83 |
+
if temp_cid is None:
|
84 |
+
return False
|
85 |
+
else:
|
86 |
+
following = self.youtube_following_list()
|
87 |
+
for f in following:
|
88 |
+
if f.channelId == cid:
|
89 |
+
return True
|
90 |
+
return False
|
91 |
+
|
92 |
+
followed = db.relationship(
|
93 |
+
'User', secondary=followers,
|
94 |
+
primaryjoin=(followers.c.follower_id == id),
|
95 |
+
secondaryjoin=(followers.c.followed_id == id),
|
96 |
+
backref=db.backref('followers', lazy='dynamic'), lazy='dynamic')
|
97 |
+
|
98 |
+
youtubeFollowed = db.relationship("youtubeFollow",
|
99 |
+
secondary=channel_association,
|
100 |
+
back_populates="followers",
|
101 |
+
lazy='dynamic')
|
102 |
+
|
103 |
+
twitterFollowed = db.relationship("twitterFollow",
|
104 |
+
secondary=twitter_association,
|
105 |
+
back_populates="followers",
|
106 |
+
lazy='dynamic')
|
107 |
+
|
108 |
+
|
109 |
+
@login.user_loader
|
110 |
+
def load_user(id):
|
111 |
+
return User.query.get(int(id))
|
112 |
+
|
113 |
+
class twitterPost():
|
114 |
+
date = 0
|
115 |
+
username = 'Error'
|
116 |
+
twitterName = "Error Name"
|
117 |
+
isPinned = False
|
118 |
+
op = 'Error'
|
119 |
+
isRT = True
|
120 |
+
urlToPost = ""
|
121 |
+
validPost = True
|
122 |
+
content = ""
|
123 |
+
profilePic = "url"
|
124 |
+
timeStamp = "error"
|
125 |
+
userProfilePic = "1.png"
|
126 |
+
isReply = False
|
127 |
+
replyingUrl = "#"
|
128 |
+
replyingUser = "@nobody"
|
129 |
+
replyingTweetContent = ""
|
130 |
+
attachedImg = ""
|
131 |
+
replyAttachedImg = ""
|
132 |
+
|
133 |
+
class ytPost():
|
134 |
+
channelName = 'Error'
|
135 |
+
channelUrl = '#'
|
136 |
+
channelId = '@'
|
137 |
+
videoUrl = '#'
|
138 |
+
videoTitle = '#'
|
139 |
+
videoThumb = '#'
|
140 |
+
description = "LOREM IPSUM"
|
141 |
+
date = 'None'
|
142 |
+
views = 'NaN'
|
143 |
+
id = 'isod'
|
144 |
+
|
145 |
+
|
146 |
+
class youtubeFollow(db.Model):
|
147 |
+
__tablename__ = 'channel'
|
148 |
+
id = db.Column(db.Integer, primary_key=True)
|
149 |
+
channelId = db.Column(db.String(30), nullable=False)
|
150 |
+
channelName = db.Column(db.String(100))
|
151 |
+
followers = db.relationship('User',
|
152 |
+
secondary=channel_association,
|
153 |
+
back_populates="youtubeFollowed")
|
154 |
+
|
155 |
+
def __repr__(self):
|
156 |
+
return f'<youtubeFollow {self.channelName}>'
|
157 |
+
|
158 |
+
class twitterFollow(db.Model):
|
159 |
+
__tablename__ = 'twitterAccount'
|
160 |
+
id = db.Column(db.Integer, primary_key=True)
|
161 |
+
username = db.Column(db.String(100), nullable=False)
|
162 |
+
followers = db.relationship('User',
|
163 |
+
secondary=twitter_association,
|
164 |
+
back_populates="twitterFollowed")
|
165 |
+
|
166 |
+
def __repr__(self):
|
167 |
+
return f'<twitterFollow {self.username}>'
|
168 |
+
|
169 |
+
class Post(db.Model):
|
170 |
+
id = db.Column(db.Integer, primary_key=True)
|
171 |
+
body = db.Column(db.String(540))
|
172 |
+
timestamp = db.Column(db.String(100))
|
173 |
+
url = db.Column(db.String(550), unique=True)
|
174 |
+
username = db.Column(db.String(100))
|
175 |
+
user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
|
176 |
+
|
177 |
+
def __repr__(self):
|
178 |
+
return f'<Post {self.body}>'
|
app/routes.py
ADDED
@@ -0,0 +1,1070 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import datetime
|
2 |
+
import glob
|
3 |
+
import json
|
4 |
+
import math
|
5 |
+
import os
|
6 |
+
import random
|
7 |
+
import re
|
8 |
+
import time
|
9 |
+
import urllib
|
10 |
+
import subprocess
|
11 |
+
from multiprocessing import Process
|
12 |
+
from concurrent.futures import as_completed
|
13 |
+
|
14 |
+
import bleach
|
15 |
+
import feedparser
|
16 |
+
import requests
|
17 |
+
from bs4 import BeautifulSoup
|
18 |
+
from flask import Response
|
19 |
+
from flask import render_template, flash, redirect, url_for, request, send_from_directory, Markup
|
20 |
+
from flask_caching import Cache
|
21 |
+
from flask_login import login_user, logout_user, current_user, login_required
|
22 |
+
from numerize import numerize
|
23 |
+
from requests_futures.sessions import FuturesSession
|
24 |
+
from werkzeug.datastructures import Headers
|
25 |
+
from werkzeug.urls import url_parse
|
26 |
+
from werkzeug.utils import secure_filename
|
27 |
+
from youtube_search import YoutubeSearch
|
28 |
+
|
29 |
+
from app import app, db
|
30 |
+
from app.forms import LoginForm, RegistrationForm, EmptyForm, SearchForm, ChannelForm
|
31 |
+
from app.models import User, twitterPost, ytPost, Post, youtubeFollow, twitterFollow
|
32 |
+
|
33 |
+
from youtube import comments, utils, channel as ytch, search as yts
|
34 |
+
from youtube import watch as ytwatch
|
35 |
+
from youtube import video as ytvid
|
36 |
+
|
37 |
+
from nitter import feed as nitterfeed
|
38 |
+
from nitter import user as nitteruser
|
39 |
+
|
40 |
+
#########################################
|
41 |
+
|
42 |
+
#########################################
|
43 |
+
|
44 |
+
cache = Cache(config={'CACHE_TYPE': 'simple'})
|
45 |
+
cache.init_app(app)
|
46 |
+
##########################
|
47 |
+
#### Config variables ####
|
48 |
+
##########################
|
49 |
+
config = json.load(open('yotter-config.json'))
|
50 |
+
##########################
|
51 |
+
#### Config variables ####
|
52 |
+
##########################
|
53 |
+
NITTERINSTANCE = config['nitterInstance'] # Must be https://.../
|
54 |
+
YOUTUBERSS = "https://www.youtube.com/feeds/videos.xml?channel_id="
|
55 |
+
|
56 |
+
|
57 |
+
##########################
|
58 |
+
#### Global variables ####
|
59 |
+
##########################
|
60 |
+
|
61 |
+
#########################
|
62 |
+
#### Twitter Logic ######
|
63 |
+
#########################
|
64 |
+
@app.before_request
|
65 |
+
def before_request():
|
66 |
+
if current_user.is_authenticated:
|
67 |
+
current_user.set_last_seen()
|
68 |
+
db.session.commit()
|
69 |
+
|
70 |
+
|
71 |
+
@app.route('/')
|
72 |
+
@app.route('/index')
|
73 |
+
@login_required
|
74 |
+
@cache.cached(timeout=50, key_prefix='home')
|
75 |
+
def index():
|
76 |
+
return render_template('home.html', config=config)
|
77 |
+
|
78 |
+
|
79 |
+
@app.route('/twitter')
|
80 |
+
@app.route('/twitter/<page>')
|
81 |
+
@login_required
|
82 |
+
def twitter(page=0):
|
83 |
+
followingList = current_user.twitter_following_list()
|
84 |
+
form = EmptyForm()
|
85 |
+
followCount = len(followingList)
|
86 |
+
page = int(page)
|
87 |
+
avatarPath = "img/avatars/1.png"
|
88 |
+
|
89 |
+
followList = []
|
90 |
+
for f in followingList:
|
91 |
+
followList.append(f.username)
|
92 |
+
posts = []
|
93 |
+
|
94 |
+
cache_file = glob.glob(f"app/cache/{current_user.username}_*")
|
95 |
+
if (len(cache_file) > 0):
|
96 |
+
time_diff = round(time.time() - os.path.getmtime(cache_file[0]))
|
97 |
+
else:
|
98 |
+
time_diff = 999
|
99 |
+
|
100 |
+
# If cache file is older than 30 minute old
|
101 |
+
if page == 0 and time_diff > 30:
|
102 |
+
if cache_file:
|
103 |
+
for f in cache_file:
|
104 |
+
os.remove(f)
|
105 |
+
feed = nitterfeed.get_feed(followList)
|
106 |
+
cache_file = f"{current_user.username}_{time.strftime('%Y%m%d-%H%M%S')}.json"
|
107 |
+
with open(f"app/cache/{cache_file}", 'w') as fp:
|
108 |
+
json.dump(feed, fp)
|
109 |
+
|
110 |
+
# Else, refresh feed
|
111 |
+
else:
|
112 |
+
try:
|
113 |
+
cache_file = glob.glob(f"app/cache/{current_user.username}*")[0]
|
114 |
+
with open(cache_file, 'r') as fp:
|
115 |
+
feed = json.load(fp)
|
116 |
+
except:
|
117 |
+
feed = nitterfeed.get_feed(followList)
|
118 |
+
cache_file = f"{current_user.username}_{time.strftime('%Y%m%d-%H%M%S')}.json"
|
119 |
+
with open(f"app/cache/{cache_file}", 'w') as fp:
|
120 |
+
json.dump(feed, fp)
|
121 |
+
|
122 |
+
posts.extend(feed)
|
123 |
+
# Items range per page
|
124 |
+
page_items = page * 16
|
125 |
+
offset = page_items + 16
|
126 |
+
# Pagination logic
|
127 |
+
init_page = page - 3
|
128 |
+
if init_page < 0:
|
129 |
+
init_page = 0
|
130 |
+
total_pages = page + 5
|
131 |
+
max_pages = int(math.ceil(len(posts) / 10)) # Total number of pages.
|
132 |
+
if total_pages > max_pages:
|
133 |
+
total_pages = max_pages
|
134 |
+
|
135 |
+
# Posts to render
|
136 |
+
if posts and len(posts) > offset:
|
137 |
+
posts = posts[page_items:offset]
|
138 |
+
else:
|
139 |
+
posts = posts[page_items:]
|
140 |
+
return render_template('twitter.html', title='Yotter | Twitter', posts=posts, followedCount=followCount, form=form, config=config,
|
141 |
+
pages=total_pages, init_page=init_page, actual_page=page)
|
142 |
+
|
143 |
+
|
144 |
+
@app.route('/savePost/<url>', methods=['POST'])
|
145 |
+
@login_required
|
146 |
+
def savePost(url):
|
147 |
+
savedUrl = url.replace('~', '/')
|
148 |
+
r = requests.get(savedUrl)
|
149 |
+
html = BeautifulSoup(str(r.content), "lxml")
|
150 |
+
post = html.body.find('div', attrs={'class': 'main-tweet'})
|
151 |
+
|
152 |
+
newPost = Post()
|
153 |
+
newPost.url = savedUrl
|
154 |
+
newPost.username = post.find('a', 'username').text.replace("@", "")
|
155 |
+
newPost.body = post.find_all('div', attrs={'class': 'tweet-content'})[0].text.encode('latin1').decode(
|
156 |
+
'unicode_escape').encode('latin1').decode('utf8')
|
157 |
+
newPost.timestamp = post.find_all('p', attrs={'class': 'tweet-published'})[0].text.encode('latin1').decode(
|
158 |
+
'unicode_escape').encode('latin1').decode('utf8')
|
159 |
+
newPost.user_id = current_user.id
|
160 |
+
try:
|
161 |
+
db.session.add(newPost)
|
162 |
+
db.session.commit()
|
163 |
+
except:
|
164 |
+
flash("Post could not be saved. Either it was already saved or there was an error.")
|
165 |
+
return redirect(request.referrer)
|
166 |
+
|
167 |
+
|
168 |
+
@app.route('/saved')
|
169 |
+
@login_required
|
170 |
+
def saved():
|
171 |
+
savedPosts = current_user.saved_posts().all()
|
172 |
+
return render_template('saved.html', title='Saved', savedPosts=savedPosts, config=config)
|
173 |
+
|
174 |
+
|
175 |
+
@app.route('/deleteSaved/<id>', methods=['POST'])
|
176 |
+
@login_required
|
177 |
+
def deleteSaved(id):
|
178 |
+
savedPost = Post.query.filter_by(id=id).first()
|
179 |
+
db.session.delete(savedPost)
|
180 |
+
db.session.commit()
|
181 |
+
return redirect(url_for('saved'))
|
182 |
+
|
183 |
+
|
184 |
+
@app.route('/follow/<username>', methods=['POST'])
|
185 |
+
@login_required
|
186 |
+
def follow(username):
|
187 |
+
form = EmptyForm()
|
188 |
+
if form.validate_on_submit():
|
189 |
+
if followTwitterAccount(username):
|
190 |
+
flash(f"{username} followed!")
|
191 |
+
return redirect(request.referrer)
|
192 |
+
|
193 |
+
|
194 |
+
def followTwitterAccount(username):
|
195 |
+
if isTwitterUser(username):
|
196 |
+
if not current_user.is_following_tw(username):
|
197 |
+
try:
|
198 |
+
follow = twitterFollow()
|
199 |
+
follow.username = username
|
200 |
+
follow.followers.append(current_user)
|
201 |
+
db.session.add(follow)
|
202 |
+
db.session.commit()
|
203 |
+
return True
|
204 |
+
except:
|
205 |
+
flash(f"Twitter: Couldn't follow {username}. Already followed?")
|
206 |
+
return False
|
207 |
+
else:
|
208 |
+
flash("Something went wrong... try again")
|
209 |
+
return False
|
210 |
+
|
211 |
+
|
212 |
+
@app.route('/unfollow/<username>', methods=['POST'])
|
213 |
+
@login_required
|
214 |
+
def unfollow(username):
|
215 |
+
form = EmptyForm()
|
216 |
+
if form.validate_on_submit():
|
217 |
+
if twUnfollow(username):
|
218 |
+
flash(f"{username} unfollowed!")
|
219 |
+
return redirect(request.referrer)
|
220 |
+
|
221 |
+
|
222 |
+
def twUnfollow(username):
|
223 |
+
try:
|
224 |
+
user = twitterFollow.query.filter_by(username=username).first()
|
225 |
+
db.session.delete(user)
|
226 |
+
db.session.commit()
|
227 |
+
except:
|
228 |
+
flash("There was an error unfollowing the user. Try again.")
|
229 |
+
return redirect(request.referrer)
|
230 |
+
|
231 |
+
|
232 |
+
@app.route('/following')
|
233 |
+
@login_required
|
234 |
+
def following():
|
235 |
+
form = EmptyForm()
|
236 |
+
followCount = len(current_user.twitter_following_list())
|
237 |
+
accounts = current_user.twitter_following_list()
|
238 |
+
return render_template('following.html', accounts=accounts, count=followCount, form=form, config=config)
|
239 |
+
|
240 |
+
|
241 |
+
@app.route('/search', methods=['GET', 'POST'])
|
242 |
+
@login_required
|
243 |
+
def search():
|
244 |
+
form = SearchForm()
|
245 |
+
if form.validate_on_submit():
|
246 |
+
user = form.username.data
|
247 |
+
results = twitterUserSearch(user)
|
248 |
+
if results:
|
249 |
+
return render_template('search.html', form=form, results=results, config=config)
|
250 |
+
else:
|
251 |
+
flash(f"User {user} not found...")
|
252 |
+
return redirect(request.referrer)
|
253 |
+
else:
|
254 |
+
return render_template('search.html', form=form, config=config)
|
255 |
+
|
256 |
+
@app.route('/u/<username>')
|
257 |
+
@app.route('/<username>')
|
258 |
+
@app.route('/<username>/<page>')
|
259 |
+
@login_required
|
260 |
+
def u(username, page=1):
|
261 |
+
page=int(page)
|
262 |
+
if username == "favicon.ico":
|
263 |
+
return redirect(url_for('static', filename='favicons/favicon.ico'))
|
264 |
+
form = EmptyForm()
|
265 |
+
avatarPath = f"img/avatars/{str(random.randint(1, 12))}.png"
|
266 |
+
user = nitteruser.get_user_info(username)
|
267 |
+
if not user:
|
268 |
+
flash("This user is not on Twitter.")
|
269 |
+
return redirect(request.referrer)
|
270 |
+
|
271 |
+
posts = []
|
272 |
+
tweets=nitteruser.get_tweets(username, page)
|
273 |
+
if tweets == 'Empty feed':
|
274 |
+
posts = False
|
275 |
+
elif tweets == 'Protected feed':
|
276 |
+
posts = 'Protected'
|
277 |
+
else:
|
278 |
+
posts.extend(tweets)
|
279 |
+
|
280 |
+
if page-1 < 0:
|
281 |
+
prev_page = 0
|
282 |
+
else:
|
283 |
+
prev_page = page-1
|
284 |
+
|
285 |
+
if page > 2:
|
286 |
+
page =2
|
287 |
+
|
288 |
+
return render_template('user.html', posts=posts, user=user, form=form, config=config, page=page, prev_page=prev_page)
|
289 |
+
|
290 |
+
|
291 |
+
#########################
|
292 |
+
#### Youtube Logic ######
|
293 |
+
#########################
|
294 |
+
@app.route('/youtube', methods=['GET', 'POST'])
|
295 |
+
@login_required
|
296 |
+
def youtube():
|
297 |
+
followCount = len(current_user.youtube_following_list())
|
298 |
+
start_time = time.time()
|
299 |
+
ids = current_user.youtube_following_list()
|
300 |
+
videos = getYoutubePosts(ids)
|
301 |
+
if videos:
|
302 |
+
videos.sort(key=lambda x: x.date, reverse=True)
|
303 |
+
print(f"--- {time.time() - start_time} seconds fetching youtube feed---")
|
304 |
+
return render_template('youtube.html', title="Yotter | Youtube", videos=videos, followCount=followCount,
|
305 |
+
config=config)
|
306 |
+
|
307 |
+
|
308 |
+
@app.route('/ytfollowing', methods=['GET', 'POST'])
|
309 |
+
@login_required
|
310 |
+
def ytfollowing():
|
311 |
+
form = EmptyForm()
|
312 |
+
channelList = current_user.youtube_following_list()
|
313 |
+
channelCount = len(channelList)
|
314 |
+
|
315 |
+
return render_template('ytfollowing.html', form=form, channelList=channelList, channelCount=channelCount,
|
316 |
+
config=config)
|
317 |
+
|
318 |
+
|
319 |
+
@app.route('/ytsearch', methods=['GET', 'POST'])
|
320 |
+
@login_required
|
321 |
+
def ytsearch():
|
322 |
+
form = ChannelForm()
|
323 |
+
button_form = EmptyForm()
|
324 |
+
query = request.args.get('q', None)
|
325 |
+
sort = request.args.get('s', None)
|
326 |
+
if sort != None:
|
327 |
+
sort = int(sort)
|
328 |
+
else:
|
329 |
+
sort = 0
|
330 |
+
|
331 |
+
page = request.args.get('p', None)
|
332 |
+
if page == None:
|
333 |
+
page = 1
|
334 |
+
|
335 |
+
if query:
|
336 |
+
autocorrect = 1
|
337 |
+
filters = {"time": 0, "type": 0, "duration": 0}
|
338 |
+
results = yts.search_by_terms(query, page, autocorrect, sort, filters)
|
339 |
+
|
340 |
+
next_page = f"/ytsearch?q={query}&s={sort}&p={int(page)+1}"
|
341 |
+
if int(page) == 1:
|
342 |
+
prev_page = f"/ytsearch?q={query}&s={sort}&p={1}"
|
343 |
+
else:
|
344 |
+
prev_page = f"/ytsearch?q={query}&s={sort}&p={int(page)-1}"
|
345 |
+
|
346 |
+
for video in results['videos']:
|
347 |
+
hostname = urllib.parse.urlparse(video['videoThumb']).netloc
|
348 |
+
video['videoThumb'] = video['videoThumb'].replace(f"https://{hostname}", "") + "&host=" + hostname
|
349 |
+
|
350 |
+
for channel in results['channels']:
|
351 |
+
if config['isInstance']:
|
352 |
+
channel['thumbnail'] = channel['thumbnail'].replace("~", "/")
|
353 |
+
hostName = urllib.parse.urlparse(channel['thumbnail']).netloc
|
354 |
+
channel['thumbnail'] = channel['thumbnail'].replace(f"https://{hostName}", "") + "?host=" + hostName
|
355 |
+
return render_template('ytsearch.html', form=form, btform=button_form, results=results,
|
356 |
+
restricted=config['restrictPublicUsage'], config=config, npage=next_page,
|
357 |
+
ppage=prev_page)
|
358 |
+
else:
|
359 |
+
return render_template('ytsearch.html', form=form, results=False)
|
360 |
+
|
361 |
+
|
362 |
+
@app.route('/ytfollow/<channelId>', methods=['POST'])
|
363 |
+
@login_required
|
364 |
+
def ytfollow(channelId):
|
365 |
+
r = followYoutubeChannel(channelId)
|
366 |
+
return redirect(request.referrer)
|
367 |
+
|
368 |
+
|
369 |
+
def followYoutubeChannel(channelId):
|
370 |
+
try:
|
371 |
+
try:
|
372 |
+
if not current_user.is_following_yt(channelId):
|
373 |
+
channelData = ytch.get_channel_tab(channelId, tab='about')
|
374 |
+
if channelData == False:
|
375 |
+
return False
|
376 |
+
follow = youtubeFollow()
|
377 |
+
follow.channelId = channelId
|
378 |
+
follow.channelName = channelData['channel_name']
|
379 |
+
follow.followers.append(current_user)
|
380 |
+
db.session.add(follow)
|
381 |
+
db.session.commit()
|
382 |
+
flash(f"{channelData['channel_name']} followed!")
|
383 |
+
return True
|
384 |
+
else:
|
385 |
+
return False
|
386 |
+
except Exception as e:
|
387 |
+
print(e)
|
388 |
+
return False
|
389 |
+
except KeyError as ke:
|
390 |
+
print(f"KeyError: {ke}:'{channelId}' could not be found")
|
391 |
+
flash(f"Youtube: ChannelId '{channelId}' is not valid")
|
392 |
+
return False
|
393 |
+
|
394 |
+
|
395 |
+
@app.route('/ytunfollow/<channelId>', methods=['POST'])
|
396 |
+
@login_required
|
397 |
+
def ytunfollow(channelId):
|
398 |
+
unfollowYoutubeChannel(channelId)
|
399 |
+
return redirect(request.referrer)
|
400 |
+
|
401 |
+
|
402 |
+
def unfollowYoutubeChannel(channelId):
|
403 |
+
try:
|
404 |
+
channel = youtubeFollow.query.filter_by(channelId=channelId).first()
|
405 |
+
name = channel.channelName
|
406 |
+
db.session.delete(channel)
|
407 |
+
db.session.commit()
|
408 |
+
channel = youtubeFollow.query.filter_by(channelId=channelId).first()
|
409 |
+
if channel:
|
410 |
+
db.session.delete(channel)
|
411 |
+
db.session.commit()
|
412 |
+
flash(f"{name} unfollowed!")
|
413 |
+
except:
|
414 |
+
flash("There was an error unfollowing the user. Try again.")
|
415 |
+
|
416 |
+
|
417 |
+
@app.route('/channel/<id>', methods=['GET'])
|
418 |
+
@app.route('/user/<id>', methods=['GET'])
|
419 |
+
@app.route('/c/<id>', methods=['GET'])
|
420 |
+
@login_required
|
421 |
+
def channel(id):
|
422 |
+
form = ChannelForm()
|
423 |
+
button_form = EmptyForm()
|
424 |
+
|
425 |
+
page = request.args.get('p', None)
|
426 |
+
sort = request.args.get('s', None)
|
427 |
+
if page is None:
|
428 |
+
page = 1
|
429 |
+
if sort is None:
|
430 |
+
sort = 3
|
431 |
+
|
432 |
+
data = ytch.get_channel_tab(id, page, sort)
|
433 |
+
for video in data['items']:
|
434 |
+
if config['isInstance']:
|
435 |
+
hostName = urllib.parse.urlparse(video['thumbnail'][1:]).netloc
|
436 |
+
video['thumbnail'] = video['thumbnail'].replace(f"https://{hostName}", "")[1:].replace("hqdefault",
|
437 |
+
"mqdefault") + "&host=" + hostName
|
438 |
+
else:
|
439 |
+
video['thumbnail'] = video['thumbnail'].replace('/', '~')
|
440 |
+
|
441 |
+
if config['isInstance']:
|
442 |
+
hostName = urllib.parse.urlparse(data['avatar'][1:]).netloc
|
443 |
+
data['avatar'] = data['avatar'].replace(f"https://{hostName}", "")[1:] + "?host=" + hostName
|
444 |
+
else:
|
445 |
+
data['avatar'] = data['avatar'].replace('/', '~')
|
446 |
+
|
447 |
+
next_page = f"/channel/{id}?s={sort}&p={int(page)+1}"
|
448 |
+
if int(page) == 1:
|
449 |
+
prev_page = f"/channel/{id}?s={sort}&p={1}"
|
450 |
+
else:
|
451 |
+
prev_page = f"/channel/{id}?s={sort}&p={int(page)-1}"
|
452 |
+
|
453 |
+
return render_template('channel.html', form=form, btform=button_form, data=data,
|
454 |
+
restricted=config['restrictPublicUsage'], config=config, next_page=next_page,
|
455 |
+
prev_page=prev_page)
|
456 |
+
|
457 |
+
|
458 |
+
def get_best_urls(urls):
|
459 |
+
'''Gets URLS in youtube format (format_id, url, height) and returns best ones for yotter'''
|
460 |
+
best_formats = ["22", "18", "34", "35", "36", "37", "38", "43", "44", "45", "46"]
|
461 |
+
best_urls = []
|
462 |
+
for url in urls:
|
463 |
+
for f in best_formats:
|
464 |
+
if url['format_id'] == f:
|
465 |
+
best_urls.append(url)
|
466 |
+
return best_urls
|
467 |
+
|
468 |
+
|
469 |
+
def get_live_urls(urls):
|
470 |
+
"""Gets URLS in youtube format (format_id, url, height) and returns best ones for yotter"""
|
471 |
+
best_formats = ["91", "92", "93", "94", "95", "96"]
|
472 |
+
best_urls = []
|
473 |
+
for url in urls:
|
474 |
+
for f in best_formats:
|
475 |
+
if url['format_id'] == f:
|
476 |
+
best_urls.append(url)
|
477 |
+
return best_urls
|
478 |
+
|
479 |
+
|
480 |
+
@app.route('/watch', methods=['GET'])
|
481 |
+
@login_required
|
482 |
+
def watch():
|
483 |
+
id = request.args.get('v', None)
|
484 |
+
info = ytvid.get_info(id)
|
485 |
+
|
486 |
+
if info['error'] == False:
|
487 |
+
for format in info['formats']:
|
488 |
+
hostName = urllib.parse.urlparse(format['url']).netloc
|
489 |
+
format['url'] = format['url'].replace(f"https://{hostName}", "") + "&host=" + hostName
|
490 |
+
|
491 |
+
for format in info['audio_formats']:
|
492 |
+
hostName = urllib.parse.urlparse(format['url']).netloc
|
493 |
+
format['url'] = format['url'].replace(f"https://{hostName}", "") + "&host=" + hostName
|
494 |
+
|
495 |
+
# Markup description
|
496 |
+
try:
|
497 |
+
info['description'] = Markup(bleach.linkify(info['description'].replace("\n", "<br>"))).replace(
|
498 |
+
'www.youtube.com', config['serverName']).replace('youtube.com', config['serverName']).replace("/join",
|
499 |
+
"")
|
500 |
+
except AttributeError or TypeError:
|
501 |
+
print(info['description'])
|
502 |
+
|
503 |
+
# Get comments
|
504 |
+
if not info['is_live']:
|
505 |
+
videocomments = comments.video_comments(id, sort=0, offset=0, lc='', secret_key='')
|
506 |
+
videocomments = utils.post_process_comments_info(videocomments)
|
507 |
+
if videocomments is not None:
|
508 |
+
videocomments.sort(key=lambda x: x['likes'], reverse=True)
|
509 |
+
else:
|
510 |
+
videocomments = False
|
511 |
+
|
512 |
+
return render_template("video.html", info=info, title=info['title'], config=config,
|
513 |
+
videocomments=videocomments)
|
514 |
+
|
515 |
+
return render_template("video.html", info=info, title='Scheduled Video', config=config)
|
516 |
+
|
517 |
+
|
518 |
+
def markupString(string):
|
519 |
+
string = string.replace("\n\n", "<br><br>").replace("\n", "<br>")
|
520 |
+
string = bleach.linkify(string)
|
521 |
+
string = string.replace("https://youtube.com/", "")
|
522 |
+
string = string.replace("https://www.youtube.com/", "")
|
523 |
+
string = string.replace("https://twitter.com/", "/u/")
|
524 |
+
return Markup(string)
|
525 |
+
|
526 |
+
|
527 |
+
## PROXY videos through Yotter server to the client.
|
528 |
+
@app.route('/stream/<url>', methods=['GET', 'POST'])
|
529 |
+
@login_required
|
530 |
+
def stream(url):
|
531 |
+
# This function proxies the video stream from GoogleVideo to the client.
|
532 |
+
url = url.replace('YotterSlash', '/')
|
533 |
+
headers = Headers()
|
534 |
+
if (url):
|
535 |
+
s = requests.Session()
|
536 |
+
s.verify = True
|
537 |
+
req = s.get(url, stream=True)
|
538 |
+
headers.add('Range', request.headers['Range'])
|
539 |
+
headers.add('Accept-Ranges', 'bytes')
|
540 |
+
headers.add('Content-Length', str(int(req.headers['Content-Length']) + 1))
|
541 |
+
response = Response(req.iter_content(chunk_size=10 * 1024), mimetype=req.headers['Content-Type'],
|
542 |
+
content_type=req.headers['Content-Type'], direct_passthrough=True, headers=headers)
|
543 |
+
# enable browser file caching with etags
|
544 |
+
response.cache_control.public = True
|
545 |
+
response.cache_control.max_age = int(60000)
|
546 |
+
return response
|
547 |
+
else:
|
548 |
+
flash("Something went wrong loading the video... Try again.")
|
549 |
+
return redirect(url_for('youtube'))
|
550 |
+
|
551 |
+
|
552 |
+
def download_file(streamable):
|
553 |
+
with streamable as stream:
|
554 |
+
stream.raise_for_status()
|
555 |
+
for chunk in stream.iter_content(chunk_size=8192):
|
556 |
+
yield chunk
|
557 |
+
|
558 |
+
|
559 |
+
#########################
|
560 |
+
#### General Logic ######
|
561 |
+
#########################
|
562 |
+
@app.route('/login', methods=['GET', 'POST'])
|
563 |
+
def login():
|
564 |
+
if current_user.is_authenticated:
|
565 |
+
return redirect(url_for('index'))
|
566 |
+
form = LoginForm()
|
567 |
+
if form.validate_on_submit():
|
568 |
+
user = User.query.filter_by(username=form.username.data).first()
|
569 |
+
if user is None or not user.check_password(form.password.data):
|
570 |
+
flash('Invalid username or password')
|
571 |
+
return redirect(url_for('login'))
|
572 |
+
if user.username == config['admin_user']:
|
573 |
+
user.set_admin_user()
|
574 |
+
db.session.commit()
|
575 |
+
login_user(user, remember=form.remember_me.data)
|
576 |
+
next_page = request.args.get('next')
|
577 |
+
if not next_page or url_parse(next_page).netloc != '':
|
578 |
+
next_page = url_for('index')
|
579 |
+
return redirect(next_page)
|
580 |
+
return render_template('login.html', title='Sign In', form=form, config=config)
|
581 |
+
|
582 |
+
|
583 |
+
# Proxy images through server
|
584 |
+
@app.route('/img/<url>', methods=['GET', 'POST'])
|
585 |
+
@login_required
|
586 |
+
def img(url):
|
587 |
+
pic = requests.get(url.replace("~", "/"))
|
588 |
+
return Response(pic, mimetype="image/png")
|
589 |
+
|
590 |
+
|
591 |
+
@app.route('/logout')
|
592 |
+
def logout():
|
593 |
+
logout_user()
|
594 |
+
return redirect(url_for('index'))
|
595 |
+
|
596 |
+
|
597 |
+
@app.route('/settings')
|
598 |
+
@login_required
|
599 |
+
@cache.cached(timeout=50, key_prefix='settings')
|
600 |
+
def settings():
|
601 |
+
active = 0
|
602 |
+
users = db.session.query(User).all()
|
603 |
+
for u in users:
|
604 |
+
if u.last_seen == None:
|
605 |
+
u.set_last_seen()
|
606 |
+
db.session.commit()
|
607 |
+
else:
|
608 |
+
t = datetime.datetime.utcnow() - u.last_seen
|
609 |
+
s = t.total_seconds()
|
610 |
+
m = s / 60
|
611 |
+
if m < 25:
|
612 |
+
active = active + 1
|
613 |
+
|
614 |
+
instanceInfo = {
|
615 |
+
"totalUsers": db.session.query(User).count(),
|
616 |
+
"active": active,
|
617 |
+
}
|
618 |
+
return render_template('settings.html', info=instanceInfo, config=config, admin=current_user.is_admin)
|
619 |
+
|
620 |
+
|
621 |
+
'''@app.route('/clear_inactive_users/<phash>')
|
622 |
+
@login_required
|
623 |
+
def clear_inactive_users(phash):
|
624 |
+
ahash = User.query.filter_by(username=config['admin_user']).first().password_hash
|
625 |
+
if phash == ahash:
|
626 |
+
users = db.session.query(User).all()
|
627 |
+
for u in users:
|
628 |
+
if u.username == config['admin_user']:
|
629 |
+
continue
|
630 |
+
t = datetime.datetime.utcnow() - u.last_seen
|
631 |
+
t = math.floor(t.total_seconds())
|
632 |
+
max_old_s = config['max_old_user_days']*86400
|
633 |
+
if t > max_old_s:
|
634 |
+
user = User.query.filter_by(username=u.username).first()
|
635 |
+
print("deleted "+u.username)
|
636 |
+
db.session.delete(user)
|
637 |
+
db.session.commit()
|
638 |
+
else:
|
639 |
+
flash("You must be admin for this action")
|
640 |
+
return redirect(request.referrer)'''
|
641 |
+
|
642 |
+
|
643 |
+
@app.route('/export')
|
644 |
+
@login_required
|
645 |
+
# Export data into a JSON file. Later you can import the data.
|
646 |
+
def export():
|
647 |
+
a = exportData()
|
648 |
+
if a:
|
649 |
+
return send_from_directory('.', 'data_export.json', as_attachment=True)
|
650 |
+
else:
|
651 |
+
return redirect(url_for('error/405'))
|
652 |
+
|
653 |
+
|
654 |
+
def exportData():
|
655 |
+
twitterFollowing = current_user.twitter_following_list()
|
656 |
+
youtubeFollowing = current_user.youtube_following_list()
|
657 |
+
data = {}
|
658 |
+
data['twitter'] = []
|
659 |
+
data['youtube'] = []
|
660 |
+
|
661 |
+
for f in twitterFollowing:
|
662 |
+
data['twitter'].append({
|
663 |
+
'username': f.username
|
664 |
+
})
|
665 |
+
|
666 |
+
for f in youtubeFollowing:
|
667 |
+
data['youtube'].append({
|
668 |
+
'channelId': f.channelId
|
669 |
+
})
|
670 |
+
|
671 |
+
try:
|
672 |
+
with open('app/data_export.json', 'w') as outfile:
|
673 |
+
json.dump(data, outfile)
|
674 |
+
return True
|
675 |
+
except:
|
676 |
+
return False
|
677 |
+
|
678 |
+
|
679 |
+
@app.route('/importdata', methods=['GET', 'POST'])
|
680 |
+
@login_required
|
681 |
+
def importdata():
|
682 |
+
if request.method == 'POST':
|
683 |
+
# check if the post request has the file part
|
684 |
+
if 'file' not in request.files:
|
685 |
+
flash('No file part')
|
686 |
+
return redirect(request.referrer)
|
687 |
+
file = request.files['file']
|
688 |
+
# if user does not select file, browser also
|
689 |
+
# submit an empty part without filename
|
690 |
+
if file.filename == '':
|
691 |
+
flash('No selected file')
|
692 |
+
return redirect(request.referrer)
|
693 |
+
else:
|
694 |
+
flash("Data is being imported. You can keep using Yotter.")
|
695 |
+
importdataasync(file)
|
696 |
+
return redirect(request.referrer)
|
697 |
+
|
698 |
+
return redirect(request.referrer)
|
699 |
+
|
700 |
+
|
701 |
+
def importdataasync(file):
|
702 |
+
p = Process(target=importdataforprocess, args=(file,))
|
703 |
+
p.start()
|
704 |
+
|
705 |
+
|
706 |
+
def importdataforprocess(file):
|
707 |
+
option = request.form['import_format']
|
708 |
+
if option == 'yotter':
|
709 |
+
importYotterSubscriptions(file)
|
710 |
+
elif option == 'youtube':
|
711 |
+
importYoutubeSubscriptions(file)
|
712 |
+
|
713 |
+
|
714 |
+
@app.route('/deleteme', methods=['GET', 'POST'])
|
715 |
+
@login_required
|
716 |
+
def deleteme():
|
717 |
+
user = User.query.filter_by(username=current_user.username).first()
|
718 |
+
db.session.delete(user)
|
719 |
+
db.session.commit()
|
720 |
+
logout_user()
|
721 |
+
return redirect(url_for('index'))
|
722 |
+
|
723 |
+
|
724 |
+
def importYoutubeSubscriptions(file):
|
725 |
+
filename = secure_filename(file.filename)
|
726 |
+
try:
|
727 |
+
data = re.findall('(UC[a-zA-Z0-9_-]{22})|(?<=user/)[a-zA-Z0-9_-]+', file.read().decode('utf-8'))
|
728 |
+
for acc in data:
|
729 |
+
r = followYoutubeChannel(acc)
|
730 |
+
except Exception as e:
|
731 |
+
print(e)
|
732 |
+
flash("File is not valid.")
|
733 |
+
|
734 |
+
|
735 |
+
def importYotterSubscriptions(file):
|
736 |
+
filename = secure_filename(file.filename)
|
737 |
+
data = json.load(file)
|
738 |
+
for acc in data['twitter']:
|
739 |
+
r = followTwitterAccount(acc['username'])
|
740 |
+
|
741 |
+
for acc in data['youtube']:
|
742 |
+
r = followYoutubeChannel(acc['channelId'])
|
743 |
+
|
744 |
+
|
745 |
+
@app.route('/register', methods=['GET', 'POST'])
|
746 |
+
def register():
|
747 |
+
form = RegistrationForm()
|
748 |
+
if current_user.is_authenticated:
|
749 |
+
return redirect(url_for('index'))
|
750 |
+
|
751 |
+
REGISTRATIONS = True
|
752 |
+
try:
|
753 |
+
count = db.session.query(User).count()
|
754 |
+
if count >= config['maxInstanceUsers'] or config['maxInstanceUsers'] == 0:
|
755 |
+
REGISTRATIONS = False
|
756 |
+
except:
|
757 |
+
REGISTRATIONS = True
|
758 |
+
|
759 |
+
if form.validate_on_submit():
|
760 |
+
if User.query.filter_by(username=form.username.data).first():
|
761 |
+
flash("This username is taken! Try with another.")
|
762 |
+
return redirect(request.referrer)
|
763 |
+
|
764 |
+
user = User(username=form.username.data)
|
765 |
+
user.set_password(form.password.data)
|
766 |
+
db.session.add(user)
|
767 |
+
db.session.commit()
|
768 |
+
flash('Congratulations, you are now a registered user!')
|
769 |
+
return redirect(url_for('login'))
|
770 |
+
|
771 |
+
return render_template('register.html', title='Register', registrations=REGISTRATIONS, form=form, config=config)
|
772 |
+
|
773 |
+
|
774 |
+
@app.route('/status')
|
775 |
+
def status():
|
776 |
+
count = db.session.query(User).count()
|
777 |
+
if count >= config['maxInstanceUsers'] or config['maxInstanceUsers'] == 0:
|
778 |
+
filen = url_for('static', filename='img/close.png')
|
779 |
+
caniregister = False
|
780 |
+
else:
|
781 |
+
filen = url_for('static', filename='img/open.png')
|
782 |
+
caniregister = True
|
783 |
+
|
784 |
+
try:
|
785 |
+
with open ("version.txt", "r") as versionFile:
|
786 |
+
ver=versionFile.readlines()
|
787 |
+
hsh = ver[0]
|
788 |
+
update= ver[1]
|
789 |
+
tag=ver[2]
|
790 |
+
except:
|
791 |
+
try:
|
792 |
+
tag = str(subprocess.check_output(["git", "describe", "--tags", "--abbrev=0"]).strip())[2:-1]
|
793 |
+
hsh = str(subprocess.check_output(["git", "rev-parse", "--short", "HEAD"]).strip())[2:-1]
|
794 |
+
update = str(subprocess.check_output(["git", "log", "-1", "--format=%cd"]).strip())[2:-7]
|
795 |
+
except:
|
796 |
+
hsh="Unknown"
|
797 |
+
update="Unknown"
|
798 |
+
tag="Unknown"
|
799 |
+
return render_template('status.html', title='STATUS', count=count, max=config['maxInstanceUsers'], file=filen,
|
800 |
+
cani=caniregister, hash=hsh, update=update, tag=tag)
|
801 |
+
|
802 |
+
|
803 |
+
@app.route('/error/<errno>')
|
804 |
+
def error(errno):
|
805 |
+
return render_template(f'{str(errno)}.html', config=config)
|
806 |
+
|
807 |
+
|
808 |
+
def getTimeDiff(t):
|
809 |
+
diff = datetime.datetime.now() - datetime.datetime(*t[:6])
|
810 |
+
|
811 |
+
if diff.days == 0:
|
812 |
+
if diff.seconds > 3599:
|
813 |
+
num = int((diff.seconds / 60) / 60)
|
814 |
+
timeString = f"{num}h"
|
815 |
+
else:
|
816 |
+
num = int(diff.seconds / 60)
|
817 |
+
timeString = f"{num}m"
|
818 |
+
else:
|
819 |
+
timeString = f"{diff.days}d"
|
820 |
+
return timeString
|
821 |
+
|
822 |
+
|
823 |
+
def isTwitterUser(username):
|
824 |
+
response = requests.get(f'{NITTERINSTANCE}{username}/rss')
|
825 |
+
if response.status_code == 404:
|
826 |
+
return False
|
827 |
+
return True
|
828 |
+
|
829 |
+
|
830 |
+
def twitterUserSearch(terms):
|
831 |
+
url = f'{NITTERINSTANCE}search?f=users&q={urllib.parse.quote(terms)}'
|
832 |
+
response = urllib.request.urlopen(url).read()
|
833 |
+
html = BeautifulSoup(str(response), "lxml")
|
834 |
+
|
835 |
+
results = []
|
836 |
+
if html.body.find('h2', attrs={'class': 'timeline-none'}):
|
837 |
+
return False
|
838 |
+
else:
|
839 |
+
html = html.body.find_all('div', attrs={'class': 'timeline-item'})
|
840 |
+
for item in html:
|
841 |
+
user = {
|
842 |
+
"fullName": item.find('a', attrs={'class': 'fullname'}).getText().encode('latin_1').decode(
|
843 |
+
'unicode_escape').encode('latin_1').decode('utf8'),
|
844 |
+
"username": item.find('a', attrs={'class': 'username'}).getText().encode('latin_1').decode(
|
845 |
+
'unicode_escape').encode('latin_1').decode('utf8'),
|
846 |
+
'avatar': NITTERINSTANCE + item.find('img', attrs={'class': 'avatar'})['src'][1:],
|
847 |
+
}
|
848 |
+
results.append(user)
|
849 |
+
return results
|
850 |
+
|
851 |
+
|
852 |
+
def getTwitterUserInfo(username):
|
853 |
+
response = urllib.request.urlopen('{NITTERINSTANCE}{username}').read()
|
854 |
+
# rssFeed = feedparser.parse(response.content)
|
855 |
+
|
856 |
+
html = BeautifulSoup(str(response), "lxml")
|
857 |
+
if html.body.find('div', attrs={'class': 'error-panel'}):
|
858 |
+
return False
|
859 |
+
else:
|
860 |
+
html = html.body.find('div', attrs={'class': 'profile-card'})
|
861 |
+
|
862 |
+
if html.find('a', attrs={'class': 'profile-card-fullname'}):
|
863 |
+
fullName = html.find('a', attrs={'class': 'profile-card-fullname'}).getText().encode('latin1').decode(
|
864 |
+
'unicode_escape').encode('latin1').decode('utf8')
|
865 |
+
else:
|
866 |
+
fullName = None
|
867 |
+
|
868 |
+
if html.find('div', attrs={'class': 'profile-bio'}):
|
869 |
+
profileBio = html.find('div', attrs={'class': 'profile-bio'}).getText().encode('latin1').decode(
|
870 |
+
'unicode_escape').encode('latin1').decode('utf8')
|
871 |
+
else:
|
872 |
+
profileBio = None
|
873 |
+
|
874 |
+
user = {
|
875 |
+
"profileFullName": fullName,
|
876 |
+
"profileUsername": html.find('a', attrs={'class': 'profile-card-username'}).string.encode('latin_1').decode(
|
877 |
+
'unicode_escape').encode('latin_1').decode('utf8'),
|
878 |
+
"profileBio": profileBio,
|
879 |
+
"tweets": html.find_all('span', attrs={'class': 'profile-stat-num'})[0].string,
|
880 |
+
"following": html.find_all('span', attrs={'class': 'profile-stat-num'})[1].string,
|
881 |
+
"followers": numerize.numerize(
|
882 |
+
int(html.find_all('span', attrs={'class': 'profile-stat-num'})[2].string.replace(",", ""))),
|
883 |
+
"likes": html.find_all('span', attrs={'class': 'profile-stat-num'})[3].string,
|
884 |
+
"profilePic": NITTERINSTANCE + html.find('a', attrs={'class': 'profile-card-avatar'})['href'][1:],
|
885 |
+
}
|
886 |
+
return user
|
887 |
+
|
888 |
+
|
889 |
+
def getFeed(urls):
|
890 |
+
feedPosts = []
|
891 |
+
with FuturesSession() as session:
|
892 |
+
futures = [session.get(f'{NITTERINSTANCE}{u.username}') for u in urls]
|
893 |
+
for future in as_completed(futures):
|
894 |
+
res= future.result().content
|
895 |
+
html = BeautifulSoup(res, "html.parser")
|
896 |
+
userFeed = html.find_all('div', attrs={'class': 'timeline-item'})
|
897 |
+
if userFeed != []:
|
898 |
+
for post in userFeed[:-1]:
|
899 |
+
date_time_str = post.find('span', attrs={'class': 'tweet-date'}).find('a')['title'].replace(",", "")
|
900 |
+
time = datetime.datetime.now() - datetime.datetime.strptime(date_time_str, '%d/%m/%Y %H:%M:%S')
|
901 |
+
if time.days >= 7:
|
902 |
+
continue
|
903 |
+
|
904 |
+
if post.find('div', attrs={'class': 'pinned'}):
|
905 |
+
if post.find('div', attrs={'class': 'pinned'}).find('span', attrs={'icon-pin'}):
|
906 |
+
continue
|
907 |
+
|
908 |
+
newPost = {}
|
909 |
+
newPost["op"] = post.find('a', attrs={'class': 'username'}).text
|
910 |
+
newPost["twitterName"] = post.find('a', attrs={'class': 'fullname'}).text
|
911 |
+
newPost["timeStamp"] = date_time_str
|
912 |
+
newPost["date"] = post.find('span', attrs={'class': 'tweet-date'}).find('a').text
|
913 |
+
content = post.find('div', attrs={'class': 'tweet-content'})
|
914 |
+
newPost["content"] = Markup(str(content).replace("\n", "<br>"))
|
915 |
+
|
916 |
+
if post.find('div', attrs={'class': 'retweet-header'}):
|
917 |
+
newPost["username"] = post.find('div', attrs={'class': 'retweet-header'}).find('div', attrs={
|
918 |
+
'class': 'icon-container'}).text
|
919 |
+
newPost["isRT"] = True
|
920 |
+
else:
|
921 |
+
newPost["username"] = newPost["op"]
|
922 |
+
newPost["isRT"] = False
|
923 |
+
|
924 |
+
newPost["profilePic"] = NITTERINSTANCE + \
|
925 |
+
post.find('a', attrs={'class': 'tweet-avatar'}).find('img')['src'][1:]
|
926 |
+
newPost["url"] = NITTERINSTANCE + post.find('a', attrs={'class': 'tweet-link'})['href'][1:]
|
927 |
+
if post.find('div', attrs={'class': 'quote'}):
|
928 |
+
newPost["isReply"] = True
|
929 |
+
quote = post.find('div', attrs={'class': 'quote'})
|
930 |
+
if quote.find('div', attrs={'class': 'quote-text'}):
|
931 |
+
newPost["replyingTweetContent"] = Markup(quote.find('div', attrs={'class': 'quote-text'}))
|
932 |
+
|
933 |
+
if quote.find('a', attrs={'class': 'still-image'}):
|
934 |
+
newPost["replyAttachedImg"] = NITTERINSTANCE + \
|
935 |
+
quote.find('a', attrs={'class': 'still-image'})['href'][1:]
|
936 |
+
|
937 |
+
if quote.find('div', attrs={'class': 'unavailable-quote'}):
|
938 |
+
newPost["replyingUser"] = "Unavailable"
|
939 |
+
else:
|
940 |
+
try:
|
941 |
+
newPost["replyingUser"] = quote.find('a', attrs={'class': 'username'}).text
|
942 |
+
except:
|
943 |
+
newPost["replyingUser"] = "Unavailable"
|
944 |
+
post.find('div', attrs={'class': 'quote'}).decompose()
|
945 |
+
|
946 |
+
if post.find('div', attrs={'class': 'attachments'}):
|
947 |
+
if not post.find(class_='quote'):
|
948 |
+
if post.find('div', attrs={'class': 'attachments'}).find('a',
|
949 |
+
attrs={'class': 'still-image'}):
|
950 |
+
newPost["attachedImg"] = NITTERINSTANCE + \
|
951 |
+
post.find('div', attrs={'class': 'attachments'}).find('a')[
|
952 |
+
'href'][1:]
|
953 |
+
feedPosts.append(newPost)
|
954 |
+
return feedPosts
|
955 |
+
|
956 |
+
|
957 |
+
def getPosts(account):
|
958 |
+
feedPosts = []
|
959 |
+
|
960 |
+
# Gather profile info.
|
961 |
+
rssFeed = urllib.request.urlopen(f'{NITTERINSTANCE}{account}').read()
|
962 |
+
# Gather feedPosts
|
963 |
+
res = rssFeed.decode('utf-8')
|
964 |
+
html = BeautifulSoup(res, "html.parser")
|
965 |
+
userFeed = html.find_all('div', attrs={'class': 'timeline-item'})
|
966 |
+
if userFeed != []:
|
967 |
+
for post in userFeed[:-1]:
|
968 |
+
date_time_str = post.find('span', attrs={'class': 'tweet-date'}).find('a')['title'].replace(",", "")
|
969 |
+
|
970 |
+
if post.find('div', attrs={'class': 'pinned'}):
|
971 |
+
if post.find('div', attrs={'class': 'pinned'}).find('span', attrs={'icon-pin'}):
|
972 |
+
continue
|
973 |
+
|
974 |
+
newPost = twitterPost()
|
975 |
+
newPost.op = post.find('a', attrs={'class': 'username'}).text
|
976 |
+
newPost.twitterName = post.find('a', attrs={'class': 'fullname'}).text
|
977 |
+
newPost.timeStamp = datetime.datetime.strptime(date_time_str, '%d/%m/%Y %H:%M:%S')
|
978 |
+
newPost.date = post.find('span', attrs={'class': 'tweet-date'}).find('a').text
|
979 |
+
newPost.content = Markup(post.find('div', attrs={'class': 'tweet-content'}))
|
980 |
+
|
981 |
+
if post.find('div', attrs={'class': 'retweet-header'}):
|
982 |
+
newPost.username = post.find('div', attrs={'class': 'retweet-header'}).find('div', attrs={
|
983 |
+
'class': 'icon-container'}).text
|
984 |
+
newPost.isRT = True
|
985 |
+
else:
|
986 |
+
newPost.username = newPost.op
|
987 |
+
newPost.isRT = False
|
988 |
+
|
989 |
+
newPost.profilePic = NITTERINSTANCE + post.find('a', attrs={'class': 'tweet-avatar'}).find('img')['src'][1:]
|
990 |
+
newPost.url = NITTERINSTANCE + post.find('a', attrs={'class': 'tweet-link'})['href'][1:]
|
991 |
+
if post.find('div', attrs={'class': 'quote'}):
|
992 |
+
newPost.isReply = True
|
993 |
+
quote = post.find('div', attrs={'class': 'quote'})
|
994 |
+
if quote.find('div', attrs={'class': 'quote-text'}):
|
995 |
+
newPost.replyingTweetContent = Markup(quote.find('div', attrs={'class': 'quote-text'}))
|
996 |
+
|
997 |
+
if quote.find('a', attrs={'class': 'still-image'}):
|
998 |
+
newPost.replyAttachedImg = NITTERINSTANCE + quote.find('a', attrs={'class': 'still-image'})['href'][
|
999 |
+
1:]
|
1000 |
+
|
1001 |
+
try:
|
1002 |
+
newPost.replyingUser = quote.find('a', attrs={'class': 'username'}).text
|
1003 |
+
except:
|
1004 |
+
newPost.replyingUser = "Unavailable"
|
1005 |
+
post.find('div', attrs={'class': 'quote'}).decompose()
|
1006 |
+
|
1007 |
+
if post.find('div', attrs={'class': 'attachments'}):
|
1008 |
+
if not post.find(class_='quote'):
|
1009 |
+
if post.find('div', attrs={'class': 'attachments'}).find('a', attrs={'class': 'still-image'}):
|
1010 |
+
newPost.attachedImg = NITTERINSTANCE + \
|
1011 |
+
post.find('div', attrs={'class': 'attachments'}).find('a')['href'][1:]
|
1012 |
+
feedPosts.append(newPost)
|
1013 |
+
return feedPosts
|
1014 |
+
|
1015 |
+
|
1016 |
+
def getYoutubePosts(ids):
|
1017 |
+
videos = []
|
1018 |
+
with FuturesSession() as session:
|
1019 |
+
futures = [session.get(f'https://www.youtube.com/feeds/videos.xml?channel_id={id.channelId}') for id in ids]
|
1020 |
+
for future in as_completed(futures):
|
1021 |
+
resp = future.result()
|
1022 |
+
rssFeed = feedparser.parse(resp.content)
|
1023 |
+
for vid in rssFeed.entries:
|
1024 |
+
try:
|
1025 |
+
# Try to get time diff
|
1026 |
+
time = datetime.datetime.now() - datetime.datetime(*vid.published_parsed[:6])
|
1027 |
+
except:
|
1028 |
+
# If youtube rss does not have parsed time, generate it. Else set time to 0.
|
1029 |
+
try:
|
1030 |
+
time = datetime.datetime.now() - datetime.datetime(
|
1031 |
+
datetime.datetime.strptime(vid.published, '%y-%m-%dT%H:%M:%S+00:00'))
|
1032 |
+
except:
|
1033 |
+
time = datetime.datetime.now() - datetime.datetime.now()
|
1034 |
+
|
1035 |
+
if time.days >= 6:
|
1036 |
+
continue
|
1037 |
+
|
1038 |
+
video = ytPost()
|
1039 |
+
try:
|
1040 |
+
video.date = vid.published_parsed
|
1041 |
+
except:
|
1042 |
+
try:
|
1043 |
+
video.date = datetime.datetime.strptime(vid.published, '%y-%m-%dT%H:%M:%S+00:00').timetuple()
|
1044 |
+
except:
|
1045 |
+
video.date = datetime.datetime.utcnow().timetuple()
|
1046 |
+
try:
|
1047 |
+
video.timeStamp = getTimeDiff(vid.published_parsed)
|
1048 |
+
except:
|
1049 |
+
if time != 0:
|
1050 |
+
video.timeStamp = f"{str(time.days)} days"
|
1051 |
+
else:
|
1052 |
+
video.timeStamp = "Unknown"
|
1053 |
+
|
1054 |
+
video.channelName = vid.author_detail.name
|
1055 |
+
video.channelId = vid.yt_channelid
|
1056 |
+
video.channelUrl = vid.author_detail.href
|
1057 |
+
video.id = vid.yt_videoid
|
1058 |
+
video.videoTitle = vid.title
|
1059 |
+
if config['isInstance']:
|
1060 |
+
hostName = urllib.parse.urlparse(vid.media_thumbnail[0]['url']).netloc
|
1061 |
+
video.videoThumb = vid.media_thumbnail[0]['url'].replace(f"https://{hostName}", "").replace(
|
1062 |
+
"hqdefault", "mqdefault") + "?host=" + hostName
|
1063 |
+
else:
|
1064 |
+
video.videoThumb = vid.media_thumbnail[0]['url'].replace('/', '~')
|
1065 |
+
video.views = vid.media_statistics['views']
|
1066 |
+
video.description = vid.summary_detail.value
|
1067 |
+
video.description = re.sub(r'^https?:\/\/.*[\r\n]*', '', video.description[0:120] + "...",
|
1068 |
+
flags=re.MULTILINE)
|
1069 |
+
videos.append(video)
|
1070 |
+
return videos
|
app/static/favicon_io.zip
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:66777e68932916136bd16308af27a52eaae7c1beca766786c575566d8309b110
|
3 |
+
size 120992
|
app/static/favicons/android-chrome-192x192.png
ADDED
![]() |
app/static/favicons/android-chrome-512x512.png
ADDED
![]() |
app/static/favicons/apple-touch-icon.png
ADDED
![]() |
app/static/favicons/favicon-16x16.png
ADDED
![]() |
app/static/favicons/favicon-32x32.png
ADDED
![]() |
app/static/favicons/favicon.ico
ADDED
|
app/static/favicons/site.webmanifest
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
{"name":"","short_name":"","icons":[{"src":"/android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"}
|
app/static/img/404.png
ADDED
![]() |
app/static/img/405.png
ADDED
![]() |
app/static/img/500.png
ADDED
![]() |
app/static/img/avatars/1.png
ADDED
![]() |
app/static/img/avatars/10.png
ADDED
![]() |
app/static/img/avatars/11.png
ADDED
![]() |
app/static/img/avatars/12.png
ADDED
![]() |
app/static/img/avatars/2.png
ADDED
![]() |
app/static/img/avatars/3.png
ADDED
![]() |
app/static/img/avatars/4.png
ADDED
![]() |
app/static/img/avatars/5.png
ADDED
![]() |
app/static/img/avatars/6.png
ADDED
![]() |
app/static/img/avatars/7.png
ADDED
![]() |
app/static/img/avatars/8.png
ADDED
![]() |
app/static/img/avatars/9.png
ADDED
![]() |
app/static/img/banner.png
ADDED
![]() |
app/static/img/close.png
ADDED
![]() |
app/static/img/closed.png
ADDED
![]() |
app/static/img/empty.png
ADDED
![]() |
app/static/img/live.png
ADDED
![]() |
app/static/img/logo.png
ADDED
![]() |
app/static/img/logo_new.png
ADDED
![]() |
app/static/img/logo_new.svg
ADDED
|
app/static/img/logo_simple.png
ADDED
![]() |