mirror of
https://github.com/Xevion/v1.xevion.dev.git
synced 2025-12-09 02:09:04 -06:00
add key_func to disable warning, simplify custom download limiter
This commit is contained in:
@@ -6,6 +6,7 @@ from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_migrate import Migrate
|
||||
from flask_login import LoginManager
|
||||
from flask_limiter import Limiter
|
||||
from flask_limiter.util import get_remote_address
|
||||
|
||||
# App & App config setup
|
||||
app = Flask(__name__)
|
||||
@@ -15,7 +16,7 @@ login = LoginManager(app)
|
||||
login.login_view = 'login'
|
||||
db = SQLAlchemy(app)
|
||||
migrate = Migrate(app, db)
|
||||
limiter = Limiter(app, default_limits=["10 per minute"])
|
||||
limiter = Limiter(app, key_func=get_remote_address, default_limits=["10 per minute"])
|
||||
|
||||
from app import models
|
||||
from app import routes, simple_routes, hidden, dashboard
|
||||
|
||||
@@ -34,9 +34,8 @@ def get_youtube(mediaid):
|
||||
# Under the request context, it grabs the same args needed to decide whether the stream has been downloaded previously
|
||||
# It applies rate limiting differently based on service, and whether the stream has been accessed previously
|
||||
def downloadLimiter():
|
||||
service, mediaid = request.view_args['service'], request.view_args['mediaid']
|
||||
if service == 'youtube':
|
||||
if YouTubeAudio.query.get(mediaid) is not None:
|
||||
if request.view_args['service'] == 'youtube':
|
||||
if YouTubeAudio.query.get(request.view_args['mediaid']) is not None:
|
||||
return '5/minute'
|
||||
else:
|
||||
return '1/30seconds'
|
||||
|
||||
Reference in New Issue
Block a user