Skip to content

Commit

Permalink
add speedfile extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
phoenixthrush committed Dec 13, 2024
1 parent 83b5dd7 commit b1e412b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
8 changes: 5 additions & 3 deletions src/aniworld/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,16 @@ def process_url(url):
"VOE",
"Vidmoly",
"Doodstream",
"Speedfiles",
"Vidoza"
],
max_height=4,
max_height=6,
value=[
[
"VOE",
"Vidmoly",
"Doodstream",
"Speedfiles",
"Vidoza"
].index(aniworld_globals.DEFAULT_PROVIDER)
],
Expand Down Expand Up @@ -345,7 +347,7 @@ def get_language_code(self, language):

def validate_provider(self, provider_selected):
logging.debug("Validating provider: %s", provider_selected)
valid_providers = ["Vidoza", "Streamtape", "VOE", "Doodstream"]
valid_providers = ["Vidoza", "Streamtape", "VOE", "Doodstream", "Speedfiles"]
while provider_selected[0] not in valid_providers:
logging.debug("Invalid provider selected, falling back to Vidoza")
npyscreen.notify_confirm(
Expand Down Expand Up @@ -514,7 +516,7 @@ def parse_arguments():
action_group.add_argument(
'-p', '--provider',
type=str,
choices=['Vidoza', 'Streamtape', 'VOE', 'Doodstream', 'Vidmoly', 'Doodstream'],
choices=['Vidoza', 'Streamtape', 'VOE', 'Doodstream', 'Vidmoly', 'Doodstream', "Speedfiles"],
help='Provider choice'
)

Expand Down
17 changes: 9 additions & 8 deletions src/aniworld/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
streamtape_get_direct_link,
vidoza_get_direct_link,
voe_get_direct_link,
vidmoly_get_direct_link
vidmoly_get_direct_link,
speedfiles_get_direct_link
)


Expand Down Expand Up @@ -58,7 +59,7 @@ def providers(soup: BeautifulSoup) -> Dict[str, Dict[int, str]]:
return None


def build_command( # pylint: disable=too-many-arguments, too-many-positional-arguments
def build_command( # pylint: disable=too-many-arguments, too-many-positional-arguments
link: str, mpv_title: str, player: str, aniskip_selected: bool, selected_provider: str,
aniskip_options: Optional[List[str]] = None
) -> List[str]:
Expand Down Expand Up @@ -195,7 +196,7 @@ def fetch_direct_link(provider_function, request_url: str) -> str:


def build_syncplay_command(
link: str, mpv_title: str, selected_provider : str, aniskip_options: Optional[List[str]] = None
link: str, mpv_title: str, selected_provider: str, aniskip_options: Optional[List[str]] = None
) -> List[str]:
logging.debug(
"Building syncplay command with link: %s, title: %s, aniskip_options: %s",
Expand Down Expand Up @@ -338,7 +339,7 @@ def process_aniskip_options(
return aniskip_options


def handle_watch_action( # pylint: disable=too-many-arguments, too-many-positional-arguments
def handle_watch_action( # pylint: disable=too-many-arguments, too-many-positional-arguments
link: str,
mpv_title: str,
aniskip_selected: bool,
Expand Down Expand Up @@ -389,7 +390,6 @@ def get_language_from_key(key: int) -> str:
else f"{sanitize_anime_title} - Movie {params['episode_number']}"
)


file_path = os.path.join(
output_directory,
sanitize_anime_title,
Expand Down Expand Up @@ -421,7 +421,7 @@ def handle_syncplay_action(
mpv_title: str,
aniskip_options: List[str],
only_command: bool,
selected_provider : str
selected_provider: str
) -> None:
logging.debug("Action is Syncplay")
mpv_title = mpv_title.replace(" --- ", " - ", 1)
Expand All @@ -432,7 +432,7 @@ def handle_syncplay_action(
print(msg)
else:
print_progress_info(msg)
command = build_syncplay_command(link, mpv_title,selected_provider, aniskip_options)
command = build_syncplay_command(link, mpv_title, selected_provider, aniskip_options)
logging.debug("Executing command: %s", command)
execute_command(command, only_command)
logging.debug("Syncplay has finished.\nBye bye!")
Expand All @@ -445,7 +445,8 @@ def execute(params: Dict[str, Any]) -> None:
"VOE": voe_get_direct_link,
"Doodstream": doodstream_get_direct_link,
"Streamtape": streamtape_get_direct_link,
"Vidmoly": vidmoly_get_direct_link
"Vidmoly": vidmoly_get_direct_link,
"Speedfiles": speedfiles_get_direct_link
}

selected_episodes = params['selected_episodes']
Expand Down
24 changes: 22 additions & 2 deletions src/aniworld/extractors/provider/speedfiles.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
def speedfiles_get_direct_link() -> str:
return "Speedfiles support is not implemented yet."
import re
import base64

SPEEDFILES_PATTERN = re.compile(r'var _0x5opu234 = "(?P<encoded_data>.*?)";')


def speedfiles_get_direct_link(soup):
data = str(soup)
match = SPEEDFILES_PATTERN.search(data)

if not match:
raise ValueError("Pattern not found in the response.")

encoded_data = match.group("encoded_data")
decoded = base64.b64decode(encoded_data).decode()
decoded = decoded.swapcase()[::-1]
decoded = base64.b64decode(decoded).decode()[::-1]
decoded_hex = ''.join(chr(int(decoded[i:i + 2], 16)) for i in range(0, len(decoded), 2))
shifted = ''.join(chr(ord(char) - 3) for char in decoded_hex)
result = base64.b64decode(shifted.swapcase()[::-1]).decode()

return result
4 changes: 2 additions & 2 deletions src/aniworld/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
DEFAULT_DOWNLOAD_PATH = os.path.join(os.path.expanduser('~'), 'Downloads')
DEFAULT_LANGUAGE = "German Sub" # German Dub, English Sub, German Sub
DEFAULT_PROVIDER = "VOE" # Vidoza, Streamtape, VOE, Doodstream
DEFAULT_PROVIDER_WATCH = "Vidoza"
DEFAULT_PROVIDER_WATCH = "Doodstream"
DEFAULT_ANISKIP = False
DEFAULT_KEEP_WATCHING = False
DEFAULT_ONLY_DIRECT_LINK = False
DEFAULT_ONLY_COMMAND = False
DEFAULT_PROXY = None
DEFAULT_USE_PLAYWRIGHT = False
DEFAULT_TERMINAL_SIZE = (90, 30)
DEFAULT_TERMINAL_SIZE = (90, 32)

log_colors = {
'DEBUG': 'bold_blue',
Expand Down

0 comments on commit b1e412b

Please sign in to comment.