Skip to content

Commit

Permalink
Merge branch 'main' of github.com:mhdzumair/MediaFusion into feature/…
Browse files Browse the repository at this point in the history
…db-migration
  • Loading branch information
mhdzumair committed Nov 20, 2024
2 parents a75106c + 6813a47 commit f653679
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
22 changes: 3 additions & 19 deletions resources/js/config_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const providerSignupLinks = {
torbox: 'https://torbox.app/subscription?referral=339b923e-fb23-40e7-8031-4af39c212e3c',
premiumize: 'https://www.premiumize.me',
qbittorrent: 'https://github.com/mhdzumair/MediaFusion/tree/main/streaming_providers/qbittorrent#qbittorrent-webdav-setup-options-with-mediafusion',
stremthru: 'https://github.com/MunifTanjim/stremthru?tab=readme-ov-file#stremthru',
};

// ---- OAuth-related Functions ----
Expand Down Expand Up @@ -323,25 +324,8 @@ function getUserData() {
if (provider) {
if (servicesRequiringUrl.includes(provider)) {
const serviceUrl = document.getElementById('service_url').value.trim();
if (!serviceUrl) {
validateInput('service_url', false);
streamingProviderData.url = '';
return;
}
let isValidUrl = false;
try {
const url = new URL(serviceUrl);
const hostname = url.hostname.toLowerCase();
// Prevent localhost and internal IPs
isValidUrl = url.protocol === 'https:' &&
!hostname.includes('localhost') &&
!hostname.match(/^127\.|^192\.168\.|^10\.|^172\.(1[6-9]|2[0-9]|3[0-1])\./);
} catch (_) {
isValidUrl = false;
}
validateInput('service_url', isValidUrl);
// Basic URL sanitization
streamingProviderData.url = isValidUrl ? serviceUrl : '';
validateInput('service_url', validateUrl(serviceUrl));
streamingProviderData.url = serviceUrl;
}
if (servicesRequiringCredentials.includes(provider)) {
validateInput('email', document.getElementById('email').value);
Expand Down
7 changes: 4 additions & 3 deletions streaming_providers/stremthru/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Optional
from urllib.parse import urljoin

from streaming_providers.debrid_client import DebridClient
from streaming_providers.exceptions import ProviderException
Expand Down Expand Up @@ -46,7 +47,7 @@ async def _make_request(
retry_count: int = 0,
) -> dict[str, Any]:
params = params or {}
url = self.BASE_URL + url
url = urljoin(self.BASE_URL, url)
response = await super()._make_request(
method,
url,
Expand All @@ -69,7 +70,7 @@ async def _make_request(

async def add_magnet_link(self, magnet_link):
response_data = await self._make_request(
"POST", "/v0/store/magnets", data={"magnet": magnet_link}
"POST", "/v0/store/magnets", json={"magnet": magnet_link}
)
return response_data

Expand All @@ -95,7 +96,7 @@ async def create_download_link(self, link):
response = await self._make_request(
"POST",
"/v0/store/link/generate",
data={"link": link},
json={"link": link},
is_expected_to_fail=True,
)
if response.get("data"):
Expand Down
1 change: 1 addition & 0 deletions utils/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
"realdebrid": "RD",
"seedr": "SDR",
"torbox": "TRB",
"stremthru": "ST",
}

CERTIFICATION_MAPPING = {
Expand Down

0 comments on commit f653679

Please sign in to comment.