forked from rDrama/rDrama
Merge branch 'frost' of https://github.com/Aevann1/rDrama into frost
commit
01689e32b8
Binary file not shown.
Before Width: | Height: | Size: 29 KiB |
|
@ -24,4 +24,5 @@ from .lottery import *
|
|||
from .casino_game import *
|
||||
from .hats import *
|
||||
from .marsey import *
|
||||
from .transactions import *
|
||||
from .transactions import *
|
||||
from .streamers import *
|
|
@ -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"<Streamer(id={self.id})>"
|
|
@ -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"
|
||||
|
||||
|
|
|
@ -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])
|
||||
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!")
|
|
@ -13,17 +13,56 @@
|
|||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
function go_to(e, link) {
|
||||
if (e.target.type != "submit")
|
||||
window.open('{{link}}', '_blank');
|
||||
}
|
||||
</script>
|
||||
|
||||
{% if error %}
|
||||
<div class="alert alert-danger alert-dismissible fade show my-3" role="alert">
|
||||
<i class="fas fa-exclamation-circle my-auto"></i>
|
||||
<span>
|
||||
{{error}}
|
||||
</span>
|
||||
<button class="close" data-bs-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if msg %}
|
||||
<div class="alert alert-success alert-dismissible fade show my-3" role="alert">
|
||||
<i class="fas fa-check-circle my-auto" aria-hidden="true"></i>
|
||||
<span>
|
||||
{{msg}}
|
||||
</span>
|
||||
<button class="close" data-bs-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true"><i class="far fa-times"></i></span>
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="px-2">
|
||||
<h1 class="py-3"><i class="fas fa-circle mr-3" style="color:red"></i>Live</h1>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="table table-striped mb-5">
|
||||
<tbody>
|
||||
{% for link, thumb, name, title, viewers in live %}
|
||||
<tr onclick="window.open('{{link}}', '_blank')">
|
||||
{% for id, link, thumb, name, title, viewers in live %}
|
||||
<tr onclick="go_to(event,'{{link}}')">
|
||||
<td width="48"><img class="thumb" src="{{thumb}}" alt="{{name}} thumbnail" referrerpolicy="no-referrer" width="48"></td>
|
||||
<td>{{name}}</td>
|
||||
<td>{{title}}</td>
|
||||
<td>{{viewers}}</td>
|
||||
{% if v and v.admin_level > 1 %}
|
||||
<td>
|
||||
<form action="/live/remove" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input type="hidden" name="id" value="{{id}}">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Remove Channel">
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
|
@ -34,16 +73,34 @@
|
|||
<div class="overflow-x-auto">
|
||||
<table class="table table-striped mb-5">
|
||||
<tbody>
|
||||
{% for link, thumb, name in offline %}
|
||||
<tr onclick="window.open('{{link}}', '_blank')">
|
||||
{% for id, link, thumb, name in offline %}
|
||||
<tr onclick="go_to(event,'{{link}}')">
|
||||
<td width="48"><img class="thumb" src="{{thumb}}" alt="{{name}} thumbnail" referrerpolicy="no-referrer" width="48"></td>
|
||||
<td>{{name}}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
{% if v and v.admin_level > 1 %}
|
||||
<td>
|
||||
<form action="/live/remove" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input type="hidden" name="id" value="{{id}}">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Remove Channel">
|
||||
</form>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% if v and v.admin_level > 1 %}
|
||||
<form action="/live/add" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input class="form-control" style="display:inline;width:350px" autocomplete="off" type="text" name="id" class="form-control" placeholder="Enter channel id.." minlength="24" maxlength="24" required>
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Add Youtube Channel" style="margin-top:-5px">
|
||||
</form>
|
||||
<p class="mt-3">you can get the channel id using this site <a href="https://streamweasels.com/tools/youtube-channel-id-and-user-id-convertor" rel="nofollow noopener noreferrer" target="_blank">https://streamweasels.com/tools/youtube-channel-id-and-user-id-convertor</a></p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -28,7 +28,7 @@
|
|||
{% if v.mods(sub.name) %}
|
||||
<form action="/h/{{sub}}/unexile/{{user.id}}" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input class="btn btn-primary" autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Unexile">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Unexile">
|
||||
</form>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<form action="/h/{{sub}}/remove_mod" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input type="hidden" name="uid" value="{{user.id}}">
|
||||
<input class="btn btn-primary" autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="{% if v.id == user.id %}Resign{% else %}Remove Mod{% endif %}">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="{% if v.id == user.id %}Resign{% else %}Remove Mod{% endif %}">
|
||||
</form>
|
||||
{% endif %}
|
||||
</td>
|
||||
|
@ -38,7 +38,7 @@
|
|||
<form action="/h/{{sub}}/add_mod" method="post">
|
||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||
<input class="form-control" style="display:inline;width:250px" autocomplete="off" type="text" name="user" class="form-control" placeholder="Enter username..">
|
||||
<input class="btn btn-primary" autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Add Mod">
|
||||
<input autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Add Mod">
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
|
|
Loading…
Reference in New Issue