Compare commits

...

4 Commits

Author SHA1 Message Date
Jill 552a5850ca wip flake 2022-08-02 11:07:06 +02:00
Jill 33af8be333 add missing dependencies to requirements.txt 2022-08-02 11:06:49 +02:00
Jill 64e93413dd specify port with envvar PORT 2022-08-02 05:49:10 +02:00
Jill b1e7e19ffa modify readme 2022-08-02 04:50:54 +02:00
6 changed files with 131 additions and 11 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
config.json
__pycache__
.vscode
.vscode
result

93
flake.lock Normal file
View File

@ -0,0 +1,93 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"mach-nix": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs",
"pypi-deps-db": "pypi-deps-db"
},
"locked": {
"lastModified": 1659091740,
"narHash": "sha256-aNtnezQfUX1QS/bFno2H5661qIY/Rn7BmHnspuuyI+4=",
"owner": "DavHau",
"repo": "mach-nix",
"rev": "f15ea8677df951cb4fe608945fd98725dcd033b3",
"type": "github"
},
"original": {
"owner": "DavHau",
"repo": "mach-nix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1643805626,
"narHash": "sha256-AXLDVMG+UaAGsGSpOtQHPIKB+IZ0KSd9WS77aanGzgc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "554d2d8aa25b6e583575459c297ec23750adb6cb",
"type": "github"
},
"original": {
"id": "nixpkgs",
"ref": "nixos-unstable",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1659412156,
"narHash": "sha256-9b0IvLVa1nsVwu3RZA715gk0XBZ1vkXv5MKH3t8lnbc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d7b20c17b4b5ab5c65756e1196bedf801c0433e9",
"type": "github"
},
"original": {
"owner": "nixos",
"repo": "nixpkgs",
"type": "github"
}
},
"pypi-deps-db": {
"flake": false,
"locked": {
"lastModified": 1643877077,
"narHash": "sha256-jv8pIvRFTP919GybOxXE5TfOkrjTbdo9QiCO1TD3ZaY=",
"owner": "DavHau",
"repo": "pypi-deps-db",
"rev": "da53397f0b782b0b18deb72ef8e0fb5aa7c98aa3",
"type": "github"
},
"original": {
"owner": "DavHau",
"repo": "pypi-deps-db",
"type": "github"
}
},
"root": {
"inputs": {
"mach-nix": "mach-nix",
"nixpkgs": "nixpkgs_2"
}
}
},
"root": "root",
"version": 7
}

24
flake.nix Normal file
View File

@ -0,0 +1,24 @@
{
description = "Minimal fork of https://github.com/Twxtter/Twxtter-main meant for embedding alongside Nitter";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
mach-nix.url = "github:DavHau/mach-nix";
};
outputs = { self, nixpkgs, mach-nix }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
baseConfig = {
requirements = builtins.readFile ./requirements.txt;
};
machNix = mach-nix.lib."${system}";
in {
devShells."${system}".default = machNix.mkPythonShell baseConfig // {
};
packages."${system}".default = machNix.mkPython baseConfig // {
};
};
}

View File

@ -2,23 +2,21 @@
(A fork of TwitFix)
Basic flask server that serves fixed twitter video embeds to desktop discord by using either the Twitter API or Youtube-DL to grab tweet video information.
This repository adds support for Nix and restricts lots of features to make running it alongside Nitter a lot simpler. You'll still have to use a custom NGINX config, however
Regarding what happened to TwitFix: http://blog.hirob.in/2022-05-16-Goodbye-TwitFix/
## How to use (discord side)
```
https://twxtter.com/[twitter video url] or [last half of twitter url])
https://nitter.oat.zone/[twitter video url] or [last half of twitter url])
```
You can also simply type out `s/i/x` on PC and iOS after sending a twitter link to discord, and it will edit the last message (The link) to replace the first i with x.
**Note**: If you enjoy this service, please considering donating via [Ko-Fi](https://ko-fi.com/twxtter) to help cover server costs
## How to run (server side)
this script uses the youtube-dl python module, along with flask, twitter and pymongo, so install those with pip (you can use `pip install -r requirements.txt`) and start the server with `python twitfix.py`
If you want to run this on a non-Nix installation, [follow the same instruction as upsteam](https://github.com/Twxtter/Twxtter-main#how-to-run-server-side)
I have included some files to give you a head start on setting this server up with uWSGI, though if you decide to use uWSGI I suggest you set up mongoDB link caching
Otherwise, import the `flake.nix` file (or run `nix flake run`)
### Config

View File

@ -2,4 +2,5 @@ Flask
youtube_dl
pymongo
twitter
flask_cors
flask_cors
requests

View File

@ -843,5 +843,8 @@ def oEmbedGen(description, user, video_link, ttype):
if __name__ == "__main__":
app.config["SERVER_NAME"] = "localhost:80"
app.run(host="0.0.0.0")
port = "80"
if "PORT" in os.environ:
port = os.environ["PORT"]
app.config["SERVER_NAME"] = "localhost:" + port
app.run(host="0.0.0.0", port=port)