Skip to content

Commit

Permalink
Revert "Replace Purple Adblock support with generic URL system"
Browse files Browse the repository at this point in the history
Reverts commit e73f2ed due to
"{channel}" breaking config parsing.
  • Loading branch information
2bc4 committed Mar 13, 2023
1 parent e73f2ed commit 11f88a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
24 changes: 12 additions & 12 deletions streamlink-ttvlol.patch
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/src/streamlink/plugins/twitch.py b/src/streamlink/plugins/twitch.py
index 8cb647fa..abd77c5f 100644
index 8cb647fa..df7ac397 100644
--- a/src/streamlink/plugins/twitch.py
+++ b/src/streamlink/plugins/twitch.py
@@ -14,7 +14,7 @@ import sys
from datetime import datetime, timedelta
from random import random
from typing import List, NamedTuple, Optional
-from urllib.parse import urlparse
+from urllib.parse import urlparse, quote
+from urllib.parse import urlparse, urlencode, quote

from streamlink.exceptions import NoStreamsError, PluginError
from streamlink.plugin import Plugin, pluginargument, pluginmatcher
Expand Down Expand Up @@ -39,7 +39,8 @@ index 8cb647fa..abd77c5f 100644
+ if not isinstance(self.excluded_channels, list):
+ self.excluded_channels = [self.excluded_channels]
+
+ def _append_url_params(self, url):
+ def _create_url(self, base, endpoint):
+ url = base + endpoint
+ params = {
+ "player": "twitchweb",
+ "type": "any",
Expand All @@ -49,23 +50,22 @@ index 8cb647fa..abd77c5f 100644
+ "fast_bread": "true",
+ }
+
+ req = self.session.http.prepare_new_request(url=url, params=params)
+ encoded_url = quote(url + '?' + urlencode(params), safe=':/')
+ req = self.session.http.prepare_new_request(url=encoded_url)
+
+ return req.url
+
+ def channel(self, channel):
+ urls = []
+
+ for proxy in self.playlist_proxies:
+ formatted_url = proxy.format(channel=channel)
+
+ url = ""
+ if formatted_url != proxy:
+ url = self._append_url_params(formatted_url)
+ else:
+ url = quote(self._append_url_params(proxy + f"/playlist/{channel}.m3u8"), safe=":/")
+ #Official Purple Adblock servers
+ #TODO: reduce spaghetti
+ if "jupter.ga" in proxy:
+ urls.append(proxy + f"/channel/{channel}")
+ continue
+
+ urls.append(url)
+ urls.append(self._create_url(proxy, f"/playlist/{channel}.m3u8"))
+
+ return urls
+
Expand Down
22 changes: 11 additions & 11 deletions twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from datetime import datetime, timedelta
from random import random
from typing import List, NamedTuple, Optional
from urllib.parse import urlparse, quote
from urllib.parse import urlparse, urlencode, quote

from streamlink.exceptions import NoStreamsError, PluginError
from streamlink.plugin import Plugin, pluginargument, pluginmatcher
Expand Down Expand Up @@ -223,7 +223,8 @@ def __init__(self, session):
if not isinstance(self.excluded_channels, list):
self.excluded_channels = [self.excluded_channels]

def _append_url_params(self, url):
def _create_url(self, base, endpoint):
url = base + endpoint
params = {
"player": "twitchweb",
"type": "any",
Expand All @@ -233,23 +234,22 @@ def _append_url_params(self, url):
"fast_bread": "true",
}

req = self.session.http.prepare_new_request(url=url, params=params)
encoded_url = quote(url + '?' + urlencode(params), safe=':/')
req = self.session.http.prepare_new_request(url=encoded_url)

return req.url

def channel(self, channel):
urls = []

for proxy in self.playlist_proxies:
formatted_url = proxy.format(channel=channel)

url = ""
if formatted_url != proxy:
url = self._append_url_params(formatted_url)
else:
url = quote(self._append_url_params(proxy + f"/playlist/{channel}.m3u8"), safe=":/")
#Official Purple Adblock servers
#TODO: reduce spaghetti
if "jupter.ga" in proxy:
urls.append(proxy + f"/channel/{channel}")
continue

urls.append(url)
urls.append(self._create_url(proxy, f"/playlist/{channel}.m3u8"))

return urls

Expand Down

0 comments on commit 11f88a6

Please sign in to comment.