From d55438afad40490417b9302304f6a308d2ff5f8f Mon Sep 17 00:00:00 2001
From: Aevann1 <59999695+Aevann1@users.noreply.github.com>
Date: Thu, 22 Sep 2022 04:17:02 +0200
Subject: [PATCH] Live (#364)
* test on devrama
* fix prev commit
* fix prev commit
* try some shit
* try some shit
* try some shit
* fix
* make it easier to change notif colors with custom css
* de
* t
* fgddfg
* fds
* fix
* fds
* dfs
* pain
* sdfsdf
* df
* xcv
* fd
* vxc
* xcv
* c
* fgdfgd
* sdf
* fsd
* fds
* sfd
* fdsf
* fd
* fds
* fds
* fsd
* fds
* fds
* fds
* fds
* fsd
* fds
* df
* fds
* dfs
* fd
* fsd
* fsd
* dfs
* sdf
* fsd
* fsd
* df
* dfs
* fd
* fsd
* dfs
* sdf
* sdf
* sdf
* fsd
* fds
* sfd
* sdf
* fds
* dfs
* df
* sdf
* sdf
* /live
---
files/routes/static.py | 57 ++++++++++++++++++++++++++++++++++++++-
files/templates/live.html | 44 ++++++++++++++++++++++++++++++
2 files changed, 100 insertions(+), 1 deletion(-)
create mode 100644 files/templates/live.html
diff --git a/files/routes/static.py b/files/routes/static.py
index 6f79af7aa..651548383 100644
--- a/files/routes/static.py
+++ b/files/routes/static.py
@@ -433,4 +433,59 @@ if not os.path.exists(f'files/templates/donate_{SITE_NAME}.html'):
@app.get('/donate')
@auth_required
def donate(v):
- return render_template(f'donate_{SITE_NAME}.html', v=v)
\ No newline at end of file
+ return render_template(f'donate_{SITE_NAME}.html', v=v)
+
+
+if SITE_NAME == 'PCM':
+ streamers = (
+ 'UCJrqlqe8DBZsfdMu7gGrVRA',
+ 'UCDDrY00FPYwLp9VqRhWiDgg',
+ 'UCdBzv8yzRgvnxV1M95qOsNA',
+ 'UCvRP7CKUHWTJamANqg8NCTQ',
+ 'UCPtDuLhreIEcjJr7WWaNaUw',
+ 'UCS8gM5S889oBPyN6K07ZC6A',
+ 'UCUn24NHjc8asGiYet1P9h5Q',
+ 'UCqdJpVkTPem_iKcoVqoZtAg',
+ 'UCtcVe3ucfS-AZVcNc2GabPw',
+ 'UCDk0PdOMRfknGhVE8R-S_DQ',
+ 'UC0UFeYG5aSGZT2e8lOjQ7oA',
+ 'UC1yC2i8t5ivhh5RsRpGWMlw',
+ 'UCP_YnD-BO8ctnKgUW89Si6Q',
+ 'UCoxFxZirbfLvy9tres71eSA',
+ 'UClf1Wfw54YBjJNlX3NjSOPA',
+ 'UC8X10knH1xD3PTeds8glyNw',
+ 'UCgKTJAN-IrVyX-jIJ5INEhA',
+ 'UCgjAbjJZgBCF3OVGkJV5kCw',
+ 'UC7xWZT4HPMFYzFoijmH8POg',
+ 'UCoBfUpZXvWjS995ZXCPxxVQ',
+ 'UCoOh1fOZBN7uCc3qu-TTAJQ',
+ 'UCo8wWQvRSoKL57vjv4vyXQw'
+ )
+
+ live_regex = re.compile('playerOverlayVideoDetailsRenderer":\{"title":\{"simpleText":"(.*?)"\},"subtitle":\{"runs":\[\{"text":"(.*?)"\},\{"text":" • "\},\{"text":"(.*?)"\}', flags=re.A)
+ live_thumb_regex = re.compile('\{"thumbnail":\{"thumbnails":\[\{"url":"(.*?)"', flags=re.A)
+ offline_regex = re.compile('","title":"(.*?)".*?"width":48,"height":48\},\{"url":"(.*?)"', flags=re.A)
+
+ @app.get('/live')
+ @app.get('/logged_out/live')
+ @auth_desired_with_logingate
+ def live(v):
+ live = []
+ offline = []
+ for x in streamers:
+ url = f'https://www.youtube.com/channel/{x}/live'
+ req = requests.get(url, cookies={'CONSENT': 'YES+1'}, proxies=proxies)
+ txt = req.text
+ if '"videoDetails":{"videoId"' in txt:
+ t = live_thumb_regex.search(txt)
+ y = live_regex.search(txt)
+ try:
+ count = int(y.group(3))
+ live.append((req.url, t.group(1), y.group(2), y.group(1), count))
+ except:
+ offline.append((req.url, t.group(1), y.group(2)))
+ else:
+ y = offline_regex.search(txt)
+ offline.append((req.url, y.group(2), y.group(1)))
+
+ return render_template(f'live.html', v=v, live=live, offline=offline)
\ No newline at end of file
diff --git a/files/templates/live.html b/files/templates/live.html
new file mode 100644
index 000000000..025afcc76
--- /dev/null
+++ b/files/templates/live.html
@@ -0,0 +1,44 @@
+{% extends "default.html" %}
+
+{% block title %}
+
{{SITE_NAME}} - Live
+{% endblock %}
+
+{% block content %}
+
+ Live
+
+
+
+ {% for link, thumb, name, title, viewers in live %}
+
+ |
+ {{name}} |
+ {{title}} |
+ {{viewers}} |
+
+ {% endfor %}
+
+
+
+
+ Offline
+
+
+
+ {% for link, thumb, name in offline %}
+
+ |
+ {{name}} |
+ |
+ |
+
+ {% endfor %}
+
+
+
+{% endblock %}
\ No newline at end of file