diff --git a/files/assets/images/rDrama/banners/115.webp b/files/assets/images/rDrama/banners/115.webp deleted file mode 100644 index 8ee0fa9c74..0000000000 Binary files a/files/assets/images/rDrama/banners/115.webp and /dev/null differ diff --git a/files/classes/__init__.py b/files/classes/__init__.py index 7e8f93c054..23647e7abe 100644 --- a/files/classes/__init__.py +++ b/files/classes/__init__.py @@ -24,4 +24,5 @@ from .lottery import * from .casino_game import * from .hats import * from .marsey import * -from .transactions import * \ No newline at end of file +from .transactions import * +from .streamers import * \ No newline at end of file diff --git a/files/classes/streamers.py b/files/classes/streamers.py new file mode 100644 index 0000000000..5754817855 --- /dev/null +++ b/files/classes/streamers.py @@ -0,0 +1,13 @@ +from files.helpers.const import SITE + +if SITE == 'pcmemes.net': + from sqlalchemy import * + from files.__main__ import Base + + class Streamer(Base): + + __tablename__ = "streamers" + id = Column(String, primary_key=True) + + def __repr__(self): + return f"" \ No newline at end of file diff --git a/files/helpers/actions.py b/files/helpers/actions.py index bd76364082..4a225a9b05 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -92,7 +92,7 @@ def execute_snappy(post, v): body += "\n\n" - if post.url and not post.url.startswith(SITE_FULL): + if post.url and not post.url.startswith(SITE_FULL) and not post.url.startswith('/') and not post.url.startswith('https://rdrama.org'): if post.url.startswith('https://old.reddit.com/r/'): rev = post.url.replace('https://old.reddit.com/', '') rev = f"* [unddit.com](https://unddit.com/{rev})\n" @@ -101,10 +101,8 @@ def execute_snappy(post, v): rev = f"* [camas.unddit.com](https://camas.unddit.com/reddit-search/#\u007b\"author\":\"{rev}\",\"resultSize\":100\u007d)\n" else: rev = '' - newposturl = post.url - if newposturl.startswith('/'): newposturl = f"{SITE_FULL}{newposturl}" - body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{newposturl})\n* [archive.ph](https://archive.ph/?url={quote(newposturl)}&run=1) (click to archive)\n* [ghostarchive.org](https://ghostarchive.org/search?term={quote(newposturl)}) (click to archive)\n\n" - archive_url(newposturl) + body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{post.url})\n* [archive.ph](https://archive.ph/?url={quote(post.url)}&run=1) (click to archive)\n* [ghostarchive.org](https://ghostarchive.org/search?term={quote(post.url)}) (click to archive)\n\n" + archive_url(post.url) captured = [] body_for_snappy = post.body_html.replace(' data-src="', ' src="') @@ -123,7 +121,7 @@ def execute_snappy(post, v): for href, title in captured: - if href.startswith(SITE_FULL): continue + if href.startswith(SITE_FULL) or href.startswith('https://rdrama.org'): continue if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n" diff --git a/files/routes/static.py b/files/routes/static.py index 260ab55db2..f52d07bee9 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -436,31 +436,8 @@ def donate(v): 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' - ) +if SITE == 'pcmemes.net': + from files.classes.streamers import * 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) @@ -470,6 +447,9 @@ if SITE_NAME == 'PCM': def live_cached(): live = [] offline = [] + db = db_session() + streamers = [x[0] for x in db.query(Streamer.id).all()] + db.close() for x in streamers: url = f'https://www.youtube.com/channel/{x}/live' req = requests.get(url, cookies={'CONSENT': 'YES+1'}, proxies=proxies) @@ -479,12 +459,12 @@ if SITE_NAME == 'PCM': 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)) + live.append((x, req.url, t.group(1), y.group(2), y.group(1), count)) except: - offline.append((req.url.rstrip('/live'), t.group(1), y.group(2))) + offline.append((x, req.url.rstrip('/live'), t.group(1), y.group(2))) else: y = offline_regex.search(txt) - try: offline.append((req.url.rstrip('/live'), y.group(2), y.group(1))) + try: offline.append((x, req.url.rstrip('/live'), y.group(2), y.group(1))) except: print(x) live = sorted(live, key=lambda x: x[4], reverse=True) @@ -495,4 +475,35 @@ if SITE_NAME == 'PCM': @app.get('/logged_out/live') @auth_desired_with_logingate def live(v): - return render_template(f'live.html', v=v, live=live_cached()[0], offline=live_cached()[1]) \ No newline at end of file + return render_template('live.html', v=v, live=live_cached()[0], offline=live_cached()[1]) + + @app.post('/live/add') + @admin_level_required(2) + def live_add(v): + id = request.values.get('id') + + if not id or len(id) != 24: + return render_template('live.html', v=v, live=live_cached()[0], offline=live_cached()[1], error="Invalid ID") + + existing = g.db.get(Streamer, id) + if not existing: + streamer = Streamer(id=id) + g.db.add(streamer) + g.db.flush() + if v.id != KIPPY_ID: + send_repeatable_notification(KIPPY_ID, f"@{v.username} has added a [new YouTube channel](https://www.youtube.com/channel/{streamer.id})") + + return render_template('live.html', v=v, live=live_cached()[0], offline=live_cached()[1], msg="Channel added successfuly!") + + @app.post('/live/remove') + @admin_level_required(2) + def live_remove(v): + id = request.values.get('id') + if not id: abort(400) + streamer = g.db.get(Streamer, id) + if streamer: + if v.id != KIPPY_ID: + send_repeatable_notification(KIPPY_ID, f"@{v.username} has removed a [YouTube channel](https://www.youtube.com/channel/{streamer.id})") + g.db.delete(streamer) + + return render_template('live.html', v=v, live=live_cached()[0], offline=live_cached()[1], msg="Channel removed successfuly!") \ No newline at end of file diff --git a/files/templates/live.html b/files/templates/live.html index 3578b37980..16438324a4 100644 --- a/files/templates/live.html +++ b/files/templates/live.html @@ -13,17 +13,56 @@ border-radius: 4px; } + + + {% if error %} + + {% endif %} + {% if msg %} + + {% endif %} +

Live

- {% for link, thumb, name, title, viewers in live %} - + {% for id, link, thumb, name, title, viewers in live %} + + {% if v and v.admin_level > 1 %} + + {% endif %} {% endfor %} @@ -34,16 +73,34 @@
{{name}} thumbnail {{name}} {{title}} {{viewers}} +
+ + + +
+
- {% for link, thumb, name in offline %} - + {% for id, link, thumb, name in offline %} + + {% if v and v.admin_level > 1 %} + + {% endif %} {% endfor %}
{{name}} thumbnail {{name}} +
+ + + +
+
+ + {% if v and v.admin_level > 1 %} +
+ + + +
+

you can get the channel id using this site https://streamweasels.com/tools/youtube-channel-id-and-user-id-convertor

+ {% endif %}
{% endblock %} \ No newline at end of file diff --git a/files/templates/sub/exilees.html b/files/templates/sub/exilees.html index 8e4e1f1344..c5f7ea8c6f 100644 --- a/files/templates/sub/exilees.html +++ b/files/templates/sub/exilees.html @@ -28,7 +28,7 @@ {% if v.mods(sub.name) %}
- +
{% endif %} diff --git a/files/templates/sub/mods.html b/files/templates/sub/mods.html index 08f1fb7a4c..6ad60d96d4 100644 --- a/files/templates/sub/mods.html +++ b/files/templates/sub/mods.html @@ -25,7 +25,7 @@
- +
{% endif %} @@ -38,7 +38,7 @@
- +
{% endif %}