Skip to content

Commit

Permalink
Back in business?
Browse files Browse the repository at this point in the history
  • Loading branch information
prof79 committed Mar 19, 2024
1 parent 38697b4 commit 06ce1fb
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 8 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,12 @@ This is a rewrite/refactoring of [Avnsx](https://github.com/Avnsx)'s original [F

⚠️ Due to a [hashing bug](../../issues/13) duplicate videos might be downloaded if a creator re-posts a lot. Downloaded videos will have to be renamed in a future version when video hashing is perfected.

### v0.9.2 2024-03-19
### v0.9.3 2024-03-19

Be warned, Fansly may ban you using this!
Be warned, Fansly may ban you using this! If you get errors be careful not to challenge your luck/try too often.

I've made the `_checkKey` configurable but don't expect this to work any more - it feels they have done more like invalidating (changing) authorization tokens and I'm probably be done with this and unsubscribe from my paid creators and I suggest you do the same.

Fansly totally lacks imagination of legit use cases like using VR where a proper media player experience requires a local library.
Well, stupid me, being overworked and tired, forgot to put an essential function call in after successful testing was complete!
Seems to work again, for now - I hope ...

For more details and history see: **[Release Notes](ReleaseNotes.md)**

Expand Down
7 changes: 7 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## 🗒️ Release Notes

### v0.9.3 2024-03-19

Be warned, Fansly may ban you using this! If you get errors be careful not to challenge your luck/try too often.

Well, stupid me, being overworked and tired, forgot to put an essential function call in after successful testing was complete!
Seems to work again, for now - I hope ...

### v0.9.2 2024-03-19

Be warned, Fansly may ban you using this!
Expand Down
4 changes: 4 additions & 0 deletions api/fansly.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(
token: str,
user_agent: str,
check_key: str,
#session_id: str,
device_id: Optional[str]=None,
device_id_timestamp: Optional[int]=None,
on_device_updated: Optional[Callable[[], Any]]=None,
Expand Down Expand Up @@ -53,6 +54,9 @@ def __init__(
self.device_id_timestamp = int(datetime(1990, 1, 1, 0, 0).timestamp())
self.update_device_id()

if self.session_id == 'null':
self.setup_session()


#region HTTP Header Management

Expand Down
8 changes: 8 additions & 0 deletions config/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ def parse_args() -> argparse.Namespace:
help="Fansly's _checkKey in the main.js on https://fansly.com. "
"Essential for digital signature and preventing bans.",
)
# parser.add_argument(
# '-sid', '--session-id',
# required=False,
# default=None,
# dest='session_id',
# help="Fansly's session ID.",
# )

#endregion Essentials

Expand Down Expand Up @@ -408,6 +415,7 @@ def map_args_to_config(args: argparse.Namespace, config: FanslyConfig) -> None:
'token',
'user_agent',
'check_key',
#'session_id',
'updated_to',
]

Expand Down
3 changes: 3 additions & 0 deletions config/fanslyconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class FanslyConfig(object):
token: str | None = None
user_agent: str | None = None
check_key: str = 'negwij-zyZnek-wavje1'
#session_id: str = 'null'

# Options
# "Normal" | "Timeline" | "Messages" | "Single" | "Collection"
Expand Down Expand Up @@ -103,6 +104,7 @@ def get_api(self) -> FanslyApi:
token=token,
user_agent=user_agent,
check_key=self.check_key,
#session_id=self.session_id,
device_id=self.cached_device_id,
device_id_timestamp=self.cached_device_id_timestamp,
on_device_updated=self._save_config,
Expand Down Expand Up @@ -155,6 +157,7 @@ def _sync_settings(self) -> None:
self._parser.set('MyAccount', 'authorization_token', self.token)
self._parser.set('MyAccount', 'user_agent', self.user_agent)
self._parser.set('MyAccount', 'check_key', self.check_key)
#self._parser.set('MyAccount', 'session_id', self.session_id)

if self.download_directory is None:
self._parser.set('Options', 'download_directory', 'Local_directory')
Expand Down
41 changes: 40 additions & 1 deletion config/validation.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Configuration Validation"""


import re
import requests

from pathlib import Path
from time import sleep
from requests.exceptions import RequestException

from textio.textio import input_enter_continue
from textio.textio import input_enter_close, input_enter_continue

from .config import username_has_valid_chars, username_has_valid_length
from .fanslyconfig import FanslyConfig
Expand Down Expand Up @@ -305,6 +306,7 @@ def validate_adjust_check_key(config: FanslyConfig) -> None:
print_warning(
f'!!! FANSLY MAY BAN YOU FOR USING THIS SOFTWARE, BE WARNED !!!'
)
print()

print_warning(
f"Make sure, checking the main.js sources of the Fansly homepage, "
Expand Down Expand Up @@ -338,6 +340,41 @@ def validate_adjust_check_key(config: FanslyConfig) -> None:
input_enter_continue()


def validate_adjust_session_id(config: FanslyConfig) -> None:
"""Validates the input value for `session_id` in `config.ini`.
:param FanslyConfig config: The configuration to validate and correct.
"""

if config.session_id is None or config.session_id.lower() == 'null':
print_warning(
f"Session ID is invalid. Please provide a valid value from your browser's DevTools:"
f"\n{20*' '}Look for `fansly-session-id` in requests or `id` from `session_active_session`"
f"\n{20*' '}in local storage for https://fansly.com (18 digits)."
)

if config.interactive:

done = False

while not done:
session_id = input(f"\n{20*' '}► Session ID: "
).strip()

if re.match(r'\d{18}', session_id):
done = True
config.session_id = session_id
save_config_or_raise(config)

else:
print_warning(
f'Invalid session ID, should be 18 digits. Please try again.'
)

else:
input_enter_close()


def validate_adjust_download_directory(config: FanslyConfig) -> None:
"""Validates the `download_directory` value from `config.ini`
and corrects it if possible.
Expand Down Expand Up @@ -389,4 +426,6 @@ def validate_adjust_config(config: FanslyConfig) -> None:

validate_adjust_check_key(config)

#validate_adjust_session_id(config)

validate_adjust_download_directory(config)
14 changes: 12 additions & 2 deletions fansly_downloader_ng.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

"""Fansly Downloader NG"""

__version__ = '0.9.2'
__date__ = '2024-03-19T22:00:00+01'
__version__ = '0.9.3'
__date__ = '2024-03-19T23:56:00+01'
__maintainer__ = 'prof79'
__copyright__ = f'Copyright (C) 2023-2024 by {__maintainer__}'
__authors__ = [
Expand Down Expand Up @@ -31,6 +31,7 @@
import traceback

#from memory_profiler import profile
from datetime import datetime

from config import FanslyConfig, load_config, validate_adjust_config
from config.args import parse_args, map_args_to_config
Expand Down Expand Up @@ -110,6 +111,15 @@ def main(config: FanslyConfig) -> int:
or config.download_mode == DownloadMode.NOTSET:
raise RuntimeError('Internal error - user name and download mode should not be empty after validation.')

print()
print_info(f'Token: {config.token}')
print_info(f'Check Key: {config.check_key}')
print_info(
f'Device ID: {config.get_api().device_id} '
f'({datetime.fromtimestamp(config.get_api().device_id_timestamp / 1000)})'
)
print_info(f'Session ID: {config.get_api().session_id}')

global_download_state = GlobalState()

# M3U8 fixing interim
Expand Down

0 comments on commit 06ce1fb

Please sign in to comment.