Compare commits
No commits in common. "fbba13afe5682a76c85bde791c462df9770f5401" and "3eb51523bbac47e71ed7ff7632f8857ab46ce255" have entirely different histories.
fbba13afe5
...
3eb51523bb
@ -1,4 +1,3 @@
|
|||||||
# Matrix youtube bot
|
# video_bot
|
||||||
|
|
||||||
A simple matrix bot that downloads youtube links and puts them on webserver so that they can be watched directly without proprietary software.
|
Matrix bot that dowloads youtube links and puts them on my website so that they can be watched 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
22
main.py
@ -15,12 +15,24 @@ class MyLogger(object):
|
|||||||
def error(self, msg):
|
def error(self, msg):
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
|
|
||||||
|
creds = botlib.Creds(config['url'], config['username'], config['password'])
|
||||||
|
bot = botlib.Bot(creds)
|
||||||
|
|
||||||
def progress_hook(d):
|
def progress_hook(d):
|
||||||
if d['status'] == 'started':
|
if d['status'] == 'started':
|
||||||
print('Started downloading')
|
print('Started downloading')
|
||||||
elif d['status'] == 'finished':
|
elif d['status'] == 'finished':
|
||||||
print('Done downloading')
|
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):
|
def get_yt_vid_id(word):
|
||||||
if search('www.youtube.com/watch', word):
|
if search('www.youtube.com/watch', word):
|
||||||
return word
|
return word
|
||||||
@ -46,14 +58,4 @@ async def youtube(room, message):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
await bot.api.send_text_message(room.room_id, str(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()
|
bot.run()
|
||||||
|
Loading…
Reference in New Issue
Block a user