Urban75 Home About Offline BrixtonBuzz Contact

Help Any Python or Ruby people here? Files won't run

sim667 I think it's just that you're using python 2 and the f-strings came in with python 3.

Code:
$ python2
Python 2.7.16 (default, Mar  4 2019, 15:29:09) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f'GET_EPISODES: Show Blacklisted: {1}'
  File "<stdin>", line 1
    f'GET_EPISODES: Show Blacklisted: {1}'
                                         ^
SyntaxError: invalid syntax
>>> 
$ python3
Python 3.7.3rc1 (default, Mar 13 2019, 11:01:15) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f'GET_EPISODES: Show Blacklisted: {1}'
'GET_EPISODES: Show Blacklisted: 1'
>>>
 
sim667 I think it's just that you're using python 2 and the f-strings came in with python 3.

Code:
$ python2
Python 2.7.16 (default, Mar  4 2019, 15:29:09) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> f'GET_EPISODES: Show Blacklisted: {1}'
  File "<stdin>", line 1
    f'GET_EPISODES: Show Blacklisted: {1}'
                                         ^
SyntaxError: invalid syntax
>>> 
$ python3
Python 3.7.3rc1 (default, Mar 13 2019, 11:01:15) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> f'GET_EPISODES: Show Blacklisted: {1}'
'GET_EPISODES: Show Blacklisted: 1'
>>>
Oh maybe. I'll try running it with python 3. Thanks
 
I'm still getting the error (line 44 for me as I've edited the blacklist, also the ^ is under the last ' ........ its out of alignment when I copy it here.


Code:
 python3 playlist_generator.py
  File "playlist_generator.py", line 44
	logger.debug(f'GET_EPISODES: Show Blacklisted: {show.title}')
															   ^
SyntaxError: invalid syntax
 
sim667 After taking out the imports I don't have it works for me with python 3 but not with python 2.

Code:
$ python2 playlist_generator.py --help
  File "playlist_generator.py", line 41
    logger.debug(f'GET_EPISODES: Show Blacklisted: {show.title}')
                                                               ^
SyntaxError: invalid syntax
$ python3 playlist_generator.py --help
usage: playlist_generator.py [-h] [--name NAME] [--number NUMBER] [--server]
                             [--baseurl BASEURL] [--token TOKEN] [--account]
                             [--username USERNAME] [--password PASSWORD]
                             [--resource RESOURCE] [--debug]

Create playlist of unwatched episodes from random shows but in correct episode
order.

optional arguments:
  -h, --help            show this help message and exit
  --name NAME           Playlist Name
  --number NUMBER, -n NUMBER
                        Number of episodes to add to play list
  --debug, -d           Debug Logging

Server Connection Method:
  --server              Server connection Method
  --baseurl BASEURL, -b BASEURL
                        Base URL of Server
  --token TOKEN, -t TOKEN
                        Authentication Token

Plex Account Connection Method:
  --account             Account Connection Method
  --username USERNAME, -u USERNAME
                        Plex Account Username
  --password PASSWORD, -p PASSWORD
                        Plex AccountPassword
  --resource RESOURCE, -r RESOURCE
                        Resource Name (Plex Server Name)
 
No weird characters/white-space at the trailing end of the line?
Might not have come across when pasting into the boards.
 
Ah I think whats happened is that it requires python 3.6..... So I've got that installed now, but when I try and run it with that it can't find plexapi which it needs..... I've installed that with pip but its installed into the 2.7 installation, so I'll have to try and work out how to install it into the python 3.6 install.
 
Very nearly there, I'm getting a problem with some of the api files its using for plex :(

Code:
Traceback (most recent call last):
  File "playlist_generator.py", line 141, in <module>
	main()
  File "playlist_generator.py", line 136, in main
	plex.playlist(title=args.name).delete()
  File "/home/username/.local/lib/python3.6/site-packages/plexapi/server.py", line 331, in playlist
	return self.fetchItem('/playlists', title=title)
  File "/home/username/.local/lib/python3.6/site-packages/plexapi/base.py", line 140, in fetchItem
	raise NotFound('Unable to find elem: cls=%s, attrs=%s' % (clsname, kwargs))
plexapi.exceptions.NotFound: Unable to find elem: cls=None, attrs={'title': 'Random Season, Next Unwatched'}
 
Sorted it, but of course its adding multiple episodes from the same show, so its not quite as random as I'd hoped haha
 
Just seen this thread now, but for future reference: I've been using pyenv for managing versions of python and it's really great.
Code:
$ pyenv install 3.7
$ pyenv local 3.7

Now anything I run in that directory will use 3.7 by default (without needing to use python3 or pip3)

You can also set it globally, too, with
Code:
$ pyenv global 3.7

And then override the global version on a directory by directory basis.
 
I looked at pyenv, but couldn't quite get my head around it...... I need some more time to play
 
Back
Top Bottom