API for parsing media from social networks
Project description
Media Parser
Server for parse Media by URL.
Supported medias
- Youtube
- Tiktok
Installation and Configuration Server
Use the docker-compose.yml
file to run the server.
version: "3.8"
service:
media-parser:
image: ghcr.io/jag-k/media-parser:latest
ports:
- 8000:8000
environment:
# Sentry integration (optional)
SENTRY_DSN: "https://abcabc@sentry.io/2"
SENTRY_ENVIRONMENT: "dev"
# Enable sentry user feedback (optional)
SENTRY_ORGANISATION_SLUG: "sentry"
SENTRY_PROJECT_SLUG: "media-parser"
SENTRY_AUTH_TOKEN: "..." # with scope project:write
SENTRY_API_HOST: "https://api.sentry.io/"
# Database
MONGO_URL: "mongodb://mongodb:27017"
MONGO_DATABASE: "test"
volumes:
- ./config:/config
mongodb:
image: mongo:latest
volumes:
- ./data:/data/db
Parsers Configuration
All configs for parsers stored in config/parsers.json
. JSON Schema for
this: schemas/parser_schema.json.
To enable parser, you need to add config for this parser.
If parser hasn't config, like tiktok
set an empty object ({}
) to enable it.
Example:
// config/parsers.json
{
"$schema": "https://raw.github.com/jag-k/media-parsers/blob/main/schemas/parser_schema.json",
"instagram": {
// Optional
"lamadava_saas_token": "asdasd"
},
"reddit": {
"client_id": "",
"client_secret": "",
// Optional
"user_agent": "video downloader (by u/Jag_k)"
},
"tiktok": {},
"twitter": {
"twitter_bearer_token": "asdasd"
},
"youtube": {}
}
Or you can use YAML file like config/parsers.yaml
or config/parsers.yml
:
# config/parsers.yml
$schema: "https://raw.github.com/jag-k/media-parsers/blob/main/schemas/parser_schema.json"
instagram:
# Optional
lamadava_saas_token: "asdasd"
reddit:
client_id: ""
client_secret: ""
# Optional
user_agent: "video downloader (by u/Jag_k)"
tiktok: {}
twitter:
twitter_bearer_token: "asdasd"
youtube: {}
Usage
API documentation available on /docs
endpoint.
Clients
Installation
poetry add media-parser # or pip install media-parser
Usage
from media_parser import Client, FeedbackTypes
client = Client("http://localhost:8000")
async def main():
# Get all media
media = await client.parse("https://www.youtube.com/watch?v=9bZkp7q19f0", user="jag-k")
print(media)
# If media is incorrect, you can send feedback
await client.send_feedback(media, "jag-k", FeedbackTypes.wrong_media)
if __name__ == '__main__':
import asyncio
asyncio.run(main())
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
media_parser-1.1.1.tar.gz
(5.5 kB
view hashes)
Built Distribution
Close
Hashes for media_parser-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a23da01080df713863f5efc242a518a9b28eeef7ab35d70c1bd2d004f8bc2b1 |
|
MD5 | c9a14564638f5ad18146d91b6de1f316 |
|
BLAKE2b-256 | ea6f96cb712057ec3cd9f428a8272be6bddf024cc8a1b6fd144579d70fc113f8 |