Compare commits

...

3 Commits

Author SHA1 Message Date
Trygve fbba13afe5 Merge branch 'master' of https://git.willy.club/Trygve/video_bot 2022-07-31 23:20:16 +02:00
Trygve df31bdd61c Updated readme 2022-07-31 23:18:04 +02:00
Trygve a864af61b3 Reorganizing 2022-07-31 22:59:30 +02:00
2 changed files with 13 additions and 14 deletions

View File

@ -1,3 +1,4 @@
# video_bot
# Matrix youtube bot
Matrix bot that dowloads youtube links and puts them on my website so that they can be watched without proprietary software.
A simple matrix bot that downloads youtube links and puts them on webserver so that they can be watched directly without proprietary software.
I have it running as [@video_bot:trygve.me](https://matrix.to/#/@video_bot:trygve.me) if you want to use it. The bot does not support encrypted rooms.

22
main.py
View File

@ -15,24 +15,12 @@ class MyLogger(object):
def error(self, msg):
print(msg)
creds = botlib.Creds(config['url'], config['username'], config['password'])
bot = botlib.Bot(creds)
def progress_hook(d):
if d['status'] == 'started':
print('Started downloading')
elif d['status'] == 'finished':
print('Done downloading')
ydl_opts = {
'format': config['yt_dlp_format'],
'outtmpl': config['download_dir'] + '/%(title)s.%(ext)s',
'restrictfilenames': True,
'logger': MyLogger(),
'progress_hooks': [progress_hook],
}
def get_yt_vid_id(word):
if search('www.youtube.com/watch', word):
return word
@ -58,4 +46,14 @@ async def youtube(room, message):
except Exception as e:
await bot.api.send_text_message(room.room_id, str(e))
creds = botlib.Creds(config['url'], config['username'], config['password'])
bot = botlib.Bot(creds)
ydl_opts = {
'format': config['yt_dlp_format'],
'outtmpl': config['download_dir'] + '/%(title)s.%(ext)s',
'restrictfilenames': True,
'logger': MyLogger(),
'progress_hooks': [progress_hook],
}
bot.run()