jensb89 / trakt---letterboxd-import

Import Letterboxd movie list (diary) into trakt.tv
90 stars 17 forks source link

Where in the Python file do I fill in `$ python py-trakt-letterboxd-import.py diary.csv` #19

Closed MikevE1995 closed 1 year ago

MikevE1995 commented 1 year ago

I've opnened the file in PyCharm but I have no idea where to put the following line: $ python py-trakt-letterboxd-import.py diary.csv

Also which of the 2 files do I need to use? py-trakt-letterboxd-import or py-trakt-letterboxd-import-python3?

MikevE1995 commented 1 year ago

I assume it would be somewhere in the part below but I have no idea where:

def usage(argv0): print('usage: '+argv0+' [OPTION] FILE ...') print(''' OPTIONS -h --help Show help --watched Use watched.csv file instead of diary (no watched date!!) --debug Turn on debuging mode (doesn't exist) EXAMPLE USAGE python py-trakt-letterboxd-import.py diary.csv ''') sys.exit(1)

I have placed it between [OPTION], although no idea if this is correct?

MikevE1995 commented 1 year ago

gettting all type of errors when trying to run the programm:

Authentication with Trakt.tv.... Authentication File not found! Trying first authentication ... Traceback (most recent call last): File "C:\Users\mikev\Downloads\trakt---letterboxd-import-master\py-trakt-letterboxd-import-python3.py", line 81, in authorize r = urllib2.urlopen(request) ^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen return opener.open(url, data, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64qbz5n2kfra8p0\Lib\urllib\request.py", line 525, in open response = meth(req, response) ^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 634, in http_response response = self.parent.error( ^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64qbz5n2kfra8p0\Lib\urllib\request.py", line 563, in error return self._call_chain(*args) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain result = func(*args) ^^^^^^^^^^^ File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 643, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 400: Bad Request

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\mikev\Downloads\trakt---letterboxd-import-master\py-trakt-letterboxd-import-python3.py", line 212, in token = check_authentication() ^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\mikev\Downloads\trakt---letterboxd-import-master\py-trakt-letterboxd-import-python3.py", line 44, in check_authentication authorize(CODE) File "C:\Users\mikev\Downloads\trakt---letterboxd-import-master\py-trakt-letterboxd-import-python3.py", line 89, in authorize raise Exception("Bad Request - request couldn't be parsed") Exception: Bad Request - request couldn't be parsed

Process finished with exit code 1

jensb89 commented 1 year ago

I've opnened the file in PyCharm but I have no idea where to put the following line: $ python py-trakt-letterboxd-import.py diary.csv

Also which of the 2 files do I need to use? py-trakt-letterboxd-import or py-trakt-letterboxd-import-python3?

Hi, so the line $ python py-trakt-letterboxd-import.py diary.csv means you call the script via python from the command line. The $ sign does not need to be typed in (under linux systems it's already printed usually, under Windows you can ignore it) If you type "python --version" on the command line, you will see which python version you have installed. If it starts with 3 you have to call the python3 script.

The errors from your last reply indicate some problems with the http requests. That means either trakt.tv has changed their API (unlikely), your python version and packages are newer and have changes incompatible with the code, there are some proxy problems on your end, there is indeed some problem with the code (but there haven't been any other issues raised) or you haven't filled in the cient id and secet. "HTTP Error 400: Bad Request" actually indicates something wrong or missing is sent to the server.

Have you filled out the following part in the code?

CLIEN_ID= '' #Fill in your client id CLIEN_SECRECT = '' #Fill in your client secred CODE = '' #Fill in your code, which you get after authorization with your trakt account

MikevE1995 commented 1 year ago

I have Python 3.11 I've also filled in the ID, secret and code

This is the error I get now:

Authentication with Trakt.tv.... Authentication File not found! Trying first authentication ... Authentication sucessfull. Saving authentication token ... Traceback (most recent call last): File "C:\Users\mikev\Downloads\trakt---letterboxd-import-master\py-trakt-letterboxd-import-python3.py", line 214, in print(letterboxd_file[0])


IndexError: list index out of range

Process finished with exit code 1

I think this is where it goes wrong:

def usage(argv0): print('usage: '+argv0+' [OPTION] FILE ...') print(''' OPTIONS -h --help Show help --watched Use watched.csv file instead of diary (no watched date!!) --debug Turn on debuging mode (doesn't exist) EXAMPLE USAGE python py-trakt-letterboxd-import.py diary.csv ''') sys.exit(1)

jensb89 commented 1 year ago

Ok, that looks already good, authentication with trakt was successful. I think you just call the script wrongly. You have to call the script with the path to your csv file, like "python py-trakt-letterboxd-import.py diary.csv"

... and diray.csv has to be in the same folder, otherwise provide the full path to the csv file in the call.

From the error it seems you are just calling "python py-trakt-letterboxd-import.py".

MikevE1995 commented 1 year ago

I need to know what this part below needs to be:

def usage(argv0): print('usage: '+argv0+' [OPTION] FILE ...') print( OPTIONS -h --help Show help --watched Use watched.csv file instead of diary (no watched date!!) --debug Turn on debuging mode (doesn't exist) EXAMPLE USAGE python py-trakt-letterboxd-import.py diary.csv ''') sys.exit(1)

jensb89 commented 1 year ago

This is just the function that is called when you provide the wrong inputs. It's called in line 200. As I said, you haven't called the script correctly, the csv file is missing and letterboxd_file is empty then.

MikevE1995 commented 1 year ago

this is line 200 for me...

    usage(sys.argv[0])

This is what I see starting at 193.

    if __name__ == "__main__":
use_diary_file = True
try:
    args, letterboxd_file = getopt.gnu_getopt(sys.argv[1:], 'h:w',[
        'help','watched'])
except:
    print("\nPlease  c h e c k   a r g u m e n t s\n\n")
    usage(sys.argv[0])

for opt, arg in args:
    if opt in ['--help', '-h']:
        usage(sys.argv[0])
    elif opt == '--watched':
        use_diary_file = False 
    else:
        print('unknown option '+opt)
        usage(sys.argv[0])

Can you send me the file with everything correctly filled in (besides the ID, secret and token)? Im not going to figure this out on my own.

jensb89 commented 1 year ago

yes, that's where the usage() function is called. The usage() function just prints some info to the console.

Except for the ID, secret and token you do not need to change anything in the file. The file is correct! You have to change your call of the file only.

How do you call the script? Via console? Via this pyCharme program? The error is not in the file but in your call.

MikevE1995 commented 1 year ago

I use the PyCharm programm to run the script

jensb89 commented 1 year ago

The call is "python .py <filepath/filename.csv>" Hereby equals to py-trakt-letterboxd-import or py-trakt-letterboxd-import3. You have to provide filepath and filename

jensb89 commented 1 year ago

I use the PyCharm programm to run the script

Then you have to check out how you can call the script with extra parameters in pyCharm. I do not use pyCharm. Here seems some help for that maybe: https://stackoverflow.com/questions/33102272/pycharm-and-sys-argv-arguments

MikevE1995 commented 1 year ago

C:\Users\mikev\Downloads\trakt---letterboxd-import-master\py-trakt-letterboxd-import-python3.py

"python py-trakt-letterboxd-import-python3.py C:\Users\mikev\Downloads\trakt---letterboxd-import-master\diary.csv"

Filled this in the script path and parameter. Still getting the error, what am I doing wrong here?

jensb89 commented 1 year ago

"python py-trakt-letterboxd-import-python3.py C:\Users\mikev\Downloads\trakt---letterboxd-import-master\diary.csv"

That looks correct. But I'm afraid I don't know much about pyCharm, there might be some extra settings needed. I work under macOS/Linux directly on the console. I can't help you with pyCharm under Windows, sorry

MikevE1995 commented 1 year ago

I can maybe run the script on my Synology NAS

MikevE1995 commented 1 year ago

File "/volume1/MEDIA-VAULT-1/trakt---letterboxd-import-master/py-trakt-letterboxd-import-python3.py", line 185 --help Show help ^ SyntaxError: invalid syntax

This is the error im getting now on my NAS. Any idea?

jensb89 commented 1 year ago

Hm, I'm sorry that it doesn't work for you. The easiest way to call it is by placing the diary.csv in the same folder, open a console (cmd under windows), go to that folder (cd directory and so on) and call python Githubissues.

  • Githubissues is a development platform for aggregating issues.