Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Issue on macos #78

Closed
samja666 opened this issue May 6, 2023 · 6 comments
Closed

Issue on macos #78

samja666 opened this issue May 6, 2023 · 6 comments
Labels
bug Something isn't working solved

Comments

@samja666
Copy link

samja666 commented May 6, 2023

On macos, i am getting an issue.

  File "fansly_scraper.py", line 48
    output(2,'\n [2]ERROR','<red>', f'"{e}" is missing or malformed in the configuration file!\n{21*" "}Read the Wiki > Explanation of provided programs & their functionality > config.ini')
                                                                                                                                                                                           ^
SyntaxError: invalid syntax

I have not modified any of your code except editing the required fields in config.ini

@samja666
Copy link
Author

samja666 commented May 6, 2023

I saw there was an exact same issue, but it had been marked as invalid and closed.
https://github.com/Avnsx/fansly/issues/55

@Avnsx
Copy link
Owner

Avnsx commented May 6, 2023

Slightly change the auth token in your config.ini file and paste the whole config.ini file here

@samja666
Copy link
Author

samja666 commented May 6, 2023

Slightly change the auth token in your config.ini file and paste the whole config.ini file here

Here you go. I have changed the token

[TargetedCreator]
username = CreatorName

[MyAccount]
authorization_token = NTExMzEyMDI0MzU4MTAwOTkyOjE6Mjo5NzY123Q3NTcxZjg2MmY3ZGM1OTNiMTZmNmQzZDU
user_agent = Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36

[Options]
show_downloads = False
download_media_previews = True
update_recent_download = Auto
open_folder_when_finished = True
naming_convention = Date_posted
seperate_messages = False
seperate_previews = False
download_directory = Local_directory

[Other]
version = 0.3.6

@Avnsx
Copy link
Owner

Avnsx commented May 8, 2023

SyntaxError: invalid syntax

So considering this is a SyntaxError, it must be an issue with your environment not supporting the way the output function is structured. Specifically the f-strings (formatted string literals).

So the python code snippet I linked right below, contains two versions of the line of code that caused this error for you. Please create a new python script, paste below snippet into it and run it, then let me know the result and the version of python that you're using to produce it.

import sys
from loguru import logger as log
from functools import partialmethod

def output(level, type, color, mytext):
    try:log.level(type, no=level, color=color)
    except TypeError:pass # level failsave
    log.__class__.type = partialmethod(log.__class__.log, type)
    log.remove()
    log.add(sys.stdout, format="<level>{level}</level> | <white>{time:HH:mm}</white> <level>|</level><light-white>| {message}</light-white>", level=type)
    log.type(mytext)

e = 'test'

# does this NOT cause a syntax error? (no additonal " around the f-string)
output(2,'\n [2]ERROR','<red>', f'{e} is missing or malformed in the configuration file!\n{21*" "}Read the Wiki > Explanation of provided programs & their functionality > config.ini')


# does this cause the syntax error? (added additional ")
output(2,'\n [2]ERROR','<red>', f'"{e}" is missing or malformed in the configuration file!\n{21*" "}Read the Wiki > Explanation of provided programs & their functionality > config.ini')

I saw there was an exact same issue, but it had been marked as invalid and closed. #55

The error you're having is not the exact same one as the guys. The guy in there modified the output function, but because of lacking programming skills he didn't understand that the function takes 4 arguments output(level, type, color, mytext) but he only passed 3 arguments, leaving out type.

But now that you pointed it out I wonder, if he maybe didn't modify the code himself, but his environment wasn't able to execute the function argument type as such, since type is also a built-in python function, maybe I should choose a different variable name that is not going to conflict with built-in names, as that might lead to unexpected errors.

So to test that also, try running this snippet below:

import sys
from loguru import logger as log
from functools import partialmethod

# renamed func argument from "type" to "log_type"
def output(level, log_type, color, mytext):
	try:log.level(log_type, no=level, color=color)
	except TypeError:pass # level failsave
	log.__class__.type = partialmethod(log.__class__.log, log_type)
	log.remove()
	log.add(sys.stdout, format="<level>{level}</level> | <white>{time:HH:mm}</white> <level>|</level><light-white>| {message}</light-white>", level=log_type)
	log.type(mytext)

e = 'test'

# does this NOT cause a syntax error? (removed newline backslash in type arg)
output(2,'[2]ERROR','<red>', f'{e} is missing or malformed in the configuration file!\n{21*" "}Read the Wiki > Explanation of provided programs & their functionality > config.ini')


# does this cause the syntax error? (keeping newline backslash in type arg)
output(2,'\n [2]ERROR','<red>', f'"{e}" is missing or malformed in the configuration file!\n{21*" "}Read the Wiki > Explanation of provided programs & their functionality > config.ini')

I myself for example can execute all of these without any errors, it might be different for you though, which is why I want you to test both of these snippets and report back to me :)

@Avnsx Avnsx added the investigating currently looking into this issue label May 8, 2023
@Avnsx
Copy link
Owner

Avnsx commented May 9, 2023

@samja666 Hey could you report back please? I want to include a fix for this in the next compiled version already

Avnsx added a commit that referenced this issue May 21, 2023
- rewrote major parts of the codebase
- rebranded to Fansly Downloader
- additonal module requirements: json, m3u8, av, time, mimetypes
    - from which only: m3u8 & av need to be installed
- option naming_convention is now deprecated & gets removed automatically
- re-named all major variables, to be more descriptive
- now reading value types, properly out of the config.ini file
- config.ini input values are now actually being validated for correctness
    - e.g. user-agent is automatically guessed now, if invalid
- update_recent_download has been improved drastically
    - now only supports Auto or False
    - its enabled by default now
    - it will be way quicker, by utilising deduplication
    - deduplication is done through 1. media id & 2. hashing now
    - hashes are added to filenames initially
    - filenames with hashes, will not get hashed again
- epoch timestamps are now converted into local systems timezone
- added alot of comments to codebase, for easier understanding
- CWD is now way more intelligently handled for all modules utilising generate_base_dir()
- added type annotations to function arguments for functions
- adapted fansly scraper for the new m3u8 video format
    - required: pyav -> pip install av
    - required: m3u8 -> pip intall m3u8
- added DUPLICATE_THRESHOLD; prevents unnecessary computation or requests to fansly
    - raises DuplicateCountError if dynamically calculated limit is exceeded
- all "modules" (Timeline, Messages etc.) are now tunneled through sort_download()
    - sort_download is a re-written version of the old namesaked function
    - it handles allocating downloads way more efficiently
    - adds media ids to filenames initially
    - if media ids are in filenames; uses them to perform deduplication with media id
    - supports all types of file extensions & mimetypes now
    - imagehash performance improved, by resizing image to 10% of original resolution b4
- all "modules" will now utilise parse_media_info() to interact with the fansly api
    - way more efficent; it doesn't just iterate & try / except blocks everything as b4
- all functions of fansly scraper are separated in modules / sections w/e
    - improves maintenance in the future & increases human readability
- re-wrote & improved logic for timeline & messages downloads
- added module for collections (#12)
- fansly downloader will now output more descriptive texts, to the currently taken action
- improved error robustness a little, need to more in the future though

fixed issues:
- fixed a issue with not escaping apostrophes on macOS (#78)
- fixed subscriber content missing (#59)
- all media file extensions are now supported (#75)
- fixed download_mode: single
    - fixed key-pair-id missing
    - fixed incorrect parsing of post creator
@Avnsx
Copy link
Owner

Avnsx commented May 21, 2023

Regardless of you not responding anymore, I am pretty sure this issue was related to not escaping apostrophes in prints.

Should be fixed with 8c591cb

Will release that 0.4 version as compiled executable within a couple days, once people start providing some feedback.

@Avnsx Avnsx closed this as completed May 21, 2023
@Avnsx Avnsx added bug Something isn't working solved and removed investigating currently looking into this issue labels May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working solved
Projects
None yet
Development

No branches or pull requests

2 participants