Format code

This commit is contained in:
2022-08-02 14:57:43 +02:00
parent 4dbdd59d8d
commit da5ece0b1c
8 changed files with 325 additions and 322 deletions

View File

@ -1,17 +1,19 @@
# discord-embed # discord-embed
Discord will only create embeds for videos and images if they are smaller than 8MB. We can "abuse" this by using the [twitter:image HTML meta tag](https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup). Discord will only create embeds for videos and images if they are smaller than 8MB. We can "abuse" this by using
the [twitter:image HTML meta tag](https://developer.twitter.com/en/docs/twitter-for-websites/cards/overview/markup).
This is useful when you send a video and want it to be playable in Discord. This is useful when you send a video and want it to be playable in Discord.
## How it works ## How it works
This program will create a .html that you will send instead of a .mp4 file. Discord will parse the HTML and create an embed for you. The embed will be the same as the one you would get if you send a .mp4 file. This program will create a .html that you will send instead of a .mp4 file. Discord will parse the HTML and create an
embed for you. The embed will be the same as the one you would get if you send a .mp4 file.
## Environment variables ## Environment variables
| Variable | Description | | Variable | Description |
| ------------- | ---------------------------------------------------------------- | |---------------|------------------------------------------------------------------|
| SERVE_DOMAIN | Domain where we server files from, not where we upload files to. | | SERVE_DOMAIN | Domain where we server files from, not where we upload files to. |
| UPLOAD_FOLDER | Path to the directory where we store files. | | UPLOAD_FOLDER | Path to the directory where we store files. |
| WEBHOOK_URL | Discord Webhook URL | | WEBHOOK_URL | Discord Webhook URL |

View File

@ -1,8 +1,8 @@
"""Read settings from environment variables.""" """Read settings from environment variables."""
import os import os
import pathlib import pathlib
import sys
import sys
from dotenv import load_dotenv from dotenv import load_dotenv
DESCRIPTION = ( DESCRIPTION = (

View File

@ -1,7 +1,6 @@
"""Stuff that has to do with videos.""" """Stuff that has to do with videos."""
import sys
import ffmpeg import ffmpeg
import sys
from discord_embed import settings from discord_embed import settings

View File

@ -6,6 +6,7 @@ body {
a:link { a:link {
color: #00AFF4; color: #00AFF4;
} }
a:visited { a:visited {
color: #00AFF4; color: #00AFF4;
} }

View File

@ -3,8 +3,8 @@
<head> <head>
<title>discord-nice-embed</title> <title>discord-nice-embed</title>
<meta content="text/html; charset=utf-8"/> <meta content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
<link rel="stylesheet" href="static/style.css" /> <link href="static/style.css" rel="stylesheet"/>
</head> </head>
<body> <body>
<h1>discord-nice-embed</h1> <h1>discord-nice-embed</h1>

View File

@ -1,12 +1,13 @@
import imghdr import imghdr
import os import os
from fastapi.testclient import TestClient
from discord_embed import __version__, settings from discord_embed import __version__, settings
from discord_embed.generate_html import generate_html_for_videos from discord_embed.generate_html import generate_html_for_videos
from discord_embed.main import app from discord_embed.main import app
from discord_embed.video import make_thumbnail, video_resolution from discord_embed.video import make_thumbnail, video_resolution
from discord_embed.webhook import send_webhook from discord_embed.webhook import send_webhook
from fastapi.testclient import TestClient
client = TestClient(app) client = TestClient(app)
TEST_FILE = "tests/test.mp4" TEST_FILE = "tests/test.mp4"