MoeFwacky / Python-Plex-Controller

Python Plex Controller
MIT License
7 stars 0 forks source link

"You must not use 8-bit bytestrings unless you use a text_facroty that can interpret 8-bit bytestrings..." #1

Closed MatthewSerinity closed 7 years ago

MatthewSerinity commented 7 years ago

While running through the setup script, after entering in which library is my 'Movies' library, I receive the following error: ` Would you like to update your system database now to add the available shows and movies in your library? Yes or No? Yes Database update starting...

Movies table has been successfully backed up. Done. Movie Table purged and ready for data. We need to update your settings to use the new movieget function. Input the name of the section that is your "Movies" section. The Following Sections are available off your server. Anime Edcational Courses Movies Music Photos TV Shows Enter Section Name: Movies Movies 1.0%Traceback (most recent call last): File "/home/pi/hasystem/upddatedb_pi.py", line 679, in getmovies() File "/home/pi/hasystem/upddatedb_pi.py", line 212, in getmovies cur.execute('INSERT INTO Movies VALUES(?, ?, ?, ?, ?, ?, ?)', (name, summary, rating, tagline, bgenre, directors, bactors)) sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. If you needed that entry for cron it was: @reboot python /home/pi/hasystem/piplaystate.py &

`

MoeFwacky commented 7 years ago

I saw something like this in earlier versions with certain special characters in titles. What movie titles are in the first 1% of your movies list? Anything with a special character? That might help narrow it down. If you change any file names, make sure you update your Plex library before populating the script database.

MatthewSerinity commented 7 years ago

Went through my movie library. The characters that messed it up were: ° in 180° South ³ in Alien³

But then I got stuck at 8.2%. 8.2% of 1247 is ~102 so I tried looking around there for special characters with no luck. Is there any way to have the script display which movie it gets caught up on or the last successfully processed movie?

MatthewSerinity commented 7 years ago

Ok, so what I did was look at what was written to myplex.db and then looked at whatever movie was after that. Not the most elegant solution, but it works.

MatthewSerinity commented 7 years ago

Now that I've corrected the Movies, it asked to update the TV Shows. It gets to 100.0% but then spits out the error "100.0%If you needed that entry for cron it was: @reboot python /home/pi/hasystem/piplaystate.py &" Followed by it kicking me out of the script

MoeFwacky commented 7 years ago

That's actually the end of the update script. That line was apparently meant as a reminder to add that line to cron if it didn't get automatically added during setup. If you didn't get any other errors, your database should be set up.

MatthewSerinity commented 7 years ago

Great. Only problem I have now is I can't use commands without using 'python system.py'. But that's a minor annoyance, not something that breaks anything.

MatthewSerinity commented 7 years ago

Actually the playme command isn't working. "ERROR: playme NOT FOUND."

MoeFwacky commented 7 years ago

Try running the add_to_bash script (maybe run the add_to_cron one too for good measure)

MatthewSerinity commented 7 years ago

Running the add_to_bash script gives me this: Traceback (most recent call last): File "add_to_bash.py", line 8, in user = str(sys.argv[1]) IndexError: list index out of range

MoeFwacky commented 7 years ago

Hmm, try running system_setup.py reset and see if it gets though the full setup and database update this time, now that you've changed the file names with special characters.

MatthewSerinity commented 7 years ago

Yeah I tried that, went ahead and redid it, the playme command still spits out the same error

MoeFwacky commented 7 years ago

Does python system.py playshow showname work?

MoeFwacky commented 7 years ago

I think I fixed the error in add_to_bash.py, either replace your existing file and run it or try wiping and reinstalling again.

MatthewSerinity commented 7 years ago

python system.py playshow showname doesn't work, it's another "NOT FOUND" error.

After re-downloading everything, running add_to_bash.py now works:

Checking for bad entries. Successfully backed up bash file... just in case.. Bad Entries have been purged. Moving on. Aliases successfully added. Adding play status files now.

add_to_chron.py however gives out this following error:

Traceback (most recent call last): File "add_to_cron.py", line 6, in user = getpass.getuser() NameError: name 'getpass' is not defined

The playme command also still doesn't work

MoeFwacky commented 7 years ago

My fault, I forgot to import getpass when I changed that method. For the playme and playshow errors, can you paste your entry and the outputs of those?

MatthewSerinity commented 7 years ago

Here's everything:

pi@raspberrypi:~ $ cd hasystem/
pi@raspberrypi:~/hasystem $ ls
add_to_bash.py  add_to_cron.py  aliases  bad_aliases  getshow.py  myplex.db  perror.txt  piplaystate.py  playstatestatus.txt  playstate.txt  playstatus.py  pstate.txt  system.py  tbn_schedule.py  upddatedb_pi.py
pi@raspberrypi:~/hasystem $ python add_to_bash.py
Checking for bad entries.
Successfully backed up bash file... just in case..
Bad Entries have been purged. Moving on.
Aliases successfully added. Adding play status files now.

pi@raspberrypi:~/hasystem $ python add_to_cron.py
Cron entry for piplaystate.py already present. No action taken.
pi@raspberrypi:~/hasystem $ python system.py playme "iZombie"
Sucessfully Added Needed CUSTOMTITLES Table.
No resume status. Setting to off.
ERROR: playme NOT FOUND.

pi@raspberrypi:~/hasystem $ python system.py playshow "iZombie"
ERROR: playshow NOT FOUND.

pi@raspberrypi:~/hasystem $ cd ..
pi@raspberrypi:~ $ playme "iZombie"
-bash: playme: command not found
pi@raspberrypi:~ $ playshow "iZombie"
-bash: playshow: command not found
pi@raspberrypi:~ $
MoeFwacky commented 7 years ago

Just to double check, you were able to successfully install the python plex api?

MatthewSerinity commented 7 years ago

Yes I did, reran the command and there were some updates avaliable though. Updated it but nothing's changed otherwise.

MoeFwacky commented 7 years ago

What version of python are you running?

MatthewSerinity commented 7 years ago

It says it's running on Python 2.7.9

MoeFwacky commented 7 years ago

Hmm, I'm at a loss. I just ran a fresh install on another pi I have, running the same version of python and the playme command worked on the first try. I also ran updatehelp after install though, but I'm not sure the two are related.

MatthewSerinity commented 7 years ago

I'll wipe my SD card and try again then. For reference, I'm using an original model B. The client is a Pi 3.

MatthewSerinity commented 7 years ago

Should I install the lite version of raspbian or the full version? That might be the issue, just remembered I installed the lite version.

MoeFwacky commented 7 years ago

I've been using the full version, so I'd give that a go.

MatthewSerinity commented 7 years ago

It's giving out the exact same errors. Wiped the SD card, downloaded the latest raspbian, followed the instructions, no dice.

pi@raspberrypi:~ $ playme "iZombie"
-bash: playme: command not found
pi@raspberrypi:~ $ playshow
-bash: playshow: command not found
pi@raspberrypi:~ $ ls
Desktop    Downloads  Music         Pictures  python_games     Templates
Documents  hasystem   oldconffiles  Public    system_setup.py  Videos
pi@raspberrypi:~ $ cd hasystem/
pi@raspberrypi:~/hasystem $ python system.py playshow "iZombie"
Sucessfully Added Needed CUSTOMTITLES Table.
No resume status. Setting to off.
ERROR: playshow NOT FOUND.

pi@raspberrypi:~/hasystem $
MoeFwacky commented 7 years ago

Hmm, I'm not sure what the issue is. Have you tried any of the other commands, including some of the status commands like listepisodes or getplaymode or playing any other titles (I admit that one is probably a long shot).

MatthewSerinity commented 7 years ago

listepisodes works as long as the title is in all lowercase, getplaymode works as well. Playing other titles doesn't change the error

pi@raspberrypi:~/hasystem $ python system.py listepisodes "izombie"
Showing Items 1 - 10 out of 41

1: Pilot
2: Brother, Can You Spare a Brain?
3: The Exterminator
4: Liv and Let Clive
5: Flight of the Living Dead
6: Virtual Reality Bites
7: Maternity Liv
8: Dead Air
9: Patriot Brains
10: Mr. Berserk

Select a number or type yes to go on. Type "quit" to exit.

Choice: quit
Done.
pi@raspberrypi:~/hasystem $ python system.py playme "izombie"
ERROR: playme NOT FOUND.

pi@raspberrypi:~/hasystem $ python system.py playme "psych"
ERROR: playme NOT FOUND.

pi@raspberrypi:~/hasystem $
MoeFwacky commented 7 years ago

It's strange that those commands specifically don't work. The only difference now between what you're running and what I'm running is the hardware (your Pi B to my Pi 2 B+). I don't think that should make a difference, but perhaps?

MatthewSerinity commented 7 years ago

Hm. I don't think it should make a difference either, but I do have a few rPi Zeros laying around. I'll try one of those and see what happens. Alternatively, maybe I could get a cloned file of your install and see if I can run it?

MoeFwacky commented 7 years ago

Here's a tar of my install. You'll probably need to delete the myplex.db file and scan that from scratch, since mine has commercials and station ID sections in addition to movies and tv shows.

edit: you'll also need to reconfigure it to point at your client and server instead of mine (RasPlex and FakeTV)

MoeFwacky commented 7 years ago

Did you have a chance to try out either my install or a different device?

MatthewSerinity commented 7 years ago

Trying yours gives me this:

We need to update your settings to use the new movieget function. Input the name                                                                                                                                                              of the section that is your "Movies" section.
The Following Sections are available off your server.
Anime
Educational Courses
Movies
Music
Photos
TV Shows
Enter Section Name: Movies
Movies
Traceback (most recent call last):
  File "/home/pi/hasystem/upddatedb_pi.py", line 679, in <module>
    getmovies()
  File "/home/pi/hasystem/upddatedb_pi.py", line 121, in getmovies
    mxlist = mlist.search("")
  File "/usr/local/lib/python2.7/dist-packages/plexapi/library.py", line 203, in                                                                                                                                                              search
    subresults = utils.listItems(self.server, query)
  File "/usr/local/lib/python2.7/dist-packages/plexapi/utils.py", line 232, in l                                                                                                                                                             istItems
    for elem in server.query(path):
  File "/usr/local/lib/python2.7/dist-packages/plexapi/server.py", line 107, in                                                                                                                                                              query
    response = method(url, headers=headers, timeout=TIMEOUT, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 469, in get
    return self.request('GET', url, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 457, in req                                                                                                                                                             uest
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/sessions.py", line 569, in sen                                                                                                                                                             d
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/dist-packages/requests/adapters.py", line 422, in sen                                                                                                                                                             d
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.1.70', port=32                                                                                                                                                             400): Read timed out. (read timeout=30)
If you needed that entry for cron it was: @reboot python /home/pi/hasystem/pipla                                                                                                                                                             ystate.py &
pi@raspberrypi:~ $
MatthewSerinity commented 7 years ago

rPi Zero isn't working either

MoeFwacky commented 7 years ago

Try this. Keep my files in the /home/pi/hasystem directory but delete myplex.db. Then run system_setup.py reset from /home/pi

Failing that run the full install again, then pack up and link me your install and I'll look at it from here and see if anything jumps out.

MatthewSerinity commented 7 years ago

It's alive!

Your setup + resetting not only allows playback, but the bash commands work now too without having to do them off of the system.py file. Works with the original rPi B.

MatthewSerinity commented 7 years ago

Also, what I find very interesting, is that I can control the rPi 3's playback with my normal TV remote. I guess it's controlling it through the HDMI.

MoeFwacky commented 7 years ago

I think rasplex as some features that play nice with some types of remotes.

Glad it's working, now to figure out why that worked but the install did not.

MatthewSerinity commented 7 years ago

If you'd like I could go grab another SD card and re-do the whole process to provide you with the files from my install. Maybe something doesn't build right because it's the original B?

MoeFwacky commented 7 years ago

Yeah, if you don't mind, that would be helpful.

MatthewSerinity commented 7 years ago

Alright I'll get back to you later.

On Jun 6, 2017 2:28 PM, "Moe Fwacky" notifications@github.com wrote:

Yeah, if you don't mind, that would be helpful.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/MoeFwacky/Python-Plex-Controller/issues/1#issuecomment-306592084, or mute the thread https://github.com/notifications/unsubscribe-auth/AIQtixtgyq-JheF_D0QUpRmbN7xTGYYbks5sBahbgaJpZM4Nu9th .