Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QNAP NAS TS-251+]Import playlist into Plex Server #12

Open
lpzantony opened this issue Jul 4, 2017 · 14 comments
Open

[QNAP NAS TS-251+]Import playlist into Plex Server #12

lpzantony opened this issue Jul 4, 2017 · 14 comments

Comments

@lpzantony
Copy link

lpzantony commented Jul 4, 2017

Hello,

My name is Antony and first of all, thanks for this project !

I am trying to use it on my Plex server running on a QNAP TS-251+. I know it it not an usual linux distro but with the correct paths, it should work.

1 - Plex directory layout

I had to change some things to make PlexPlaylistImporter.py work :

Line 93 old :
PlexDBPath=(os.environ['PLEX_HOME']+'/Library/Application Support/Plex Media Server/' if 'PLEX_HOME' in os.environ else '')
Line 93 new :
PlexDBPath=(os.environ['PLEX_HOME']+'/Library/Plex Media Server/' if 'PLEX_HOME' in os.environ else '')

I had to delete Application Support from the PlexBDPath variable since the Qnap package of Plex Server seems to have a different directory layout then the one your script expects.

2 - Symbolic links

I also struggled with the symbolic links made by the QNAP OS but printing what MP.file gave from the Plex database, i was abble to set the correct path in my .m3u files.

Here is the code I added toPlexPlaylistImporter.py (line 138) to determine the path used by Plex database:

Cur.execute('SELECT MP.file FROM media_parts AS MP INNER JOIN media_items AS MI ON MI.id=MP.media_item_id  COLLATE NOCASE',) 
        for row in Cur:
            print(row[0])
            print("FilePath = " + FilePath)

This way I could compare the path given by my playlist and the one stored in the Plex database. Of course, I deleted this code as soon I figured out the correct path.

I have .m3u8 files ( from the PowerAmp Android app) to be precise but the patern is exactly the same : absolute path to the files and one file per line.

Final playlist file

Here is a sample of my playlist files :

/share/CE_CACHEDEV1_DATA/.qpkg/CodexPack/mnt/share/CE_CACHEDEV1_DATA/Multimedia/MUSIQUE/Morceaux/Grand Corps Malade_Midi 20/13 Grand Corps Malade - Vu De Ma Fenêtre.flac
/share/CE_CACHEDEV1_DATA/.qpkg/CodexPack/mnt/share/CE_CACHEDEV1_DATA/Multimedia/MUSIQUE/Morceaux/Grand Corps Malade_Midi 20/14 Grand Corps Malade - Rencontres.flac
/share/CE_CACHEDEV1_DATA/.qpkg/CodexPack/mnt/share/CE_CACHEDEV1_DATA/Multimedia/MUSIQUE/Morceaux/Grand Corps Malade - 3eme Temps/03-grand_corps_malade-a_lecole_de_la_vie.mp3

My issue

With my .m3u8 modified with correct paths and the PlexPlaylistImporter.py file edited, i successfully imported the playlists according to the script output but I can't see any of my playlists in Plex, even after rebooting the NAS :

> PlaylistImporter -f /share/CE_CACHEDEV1_DATA/Multimedia/MUSIQUE/Playlists/Slam.m3u8
> Playlist name (Cannot be blank): Slam
> 59 items imported

I know my use case is quite unusual but I hoped that you may have an idea about why the playlists don't show up at all in Plex even with a successfull output from your script.

Regards

Antony

@dakusan
Copy link
Owner

dakusan commented Jul 4, 2017

I'll look through the rest of what you said after we confirm my first thought is wrong. This exact same scenario just happened for the first time in an "Issues" request within the last week or two) Is it possible you have multiple plex accounts on the server and you are importing it into a different one? If so, the most recent source version has 2 flags to specify the plex user.

@lpzantony
Copy link
Author

lpzantony commented Jul 5, 2017

Indeed, I saw the -i and -n options but I didn't used it to avoid making mistakes at first.

The thing is, I can't figure out the difference between -n and -i:

  -i Account_ID, --account-id Account_ID
                        The id of plex account to add playlist to if not
                        master.
  -n Account_Name, --account-name Account_Name
                        The name of plex account to add playlist to if not
                        master.

My Plex username that I use to sign in the website (here : https://www.plex.tv/sign-in/) or the dedicated client is Socra16 but I can't tell if it is an Account_ID or an Account_Name.

The thing I know : in Plex Server >> Settings >> Users >> My Home I only have my account registered:

capture

So should I type in :

> PlexPlaylistImporter -i Socra16 Code.m3u8 Code

 // Or

> PlexPlaylistImporter -n Socra16 Code.m3u8 Code

// Or

> PlexPlaylistImporter -i Socra16 -n Socra16 Code.m3u8 Code

Sorry for all those questions, I just want to make sure I understand clearly what you are talking about.

@dakusan
Copy link
Owner

dakusan commented Jul 5, 2017

-n Socra16 should be correct. You might also try -i 0, -i 1, and -i 2 (I do not recall off the top of my head if the ID is 0 based)

@lpzantony
Copy link
Author

lpzantony commented Jul 5, 2017

Hello there,
Just tried -n Socra16 with -i 0, -i1 and -i 2 but same result, nothing appears in Plex :

> PlexPlaylistImporter -f -n Socra16 -i 0 Boite.m3u8 Boite
86 items imported
> PlexPlaylistImporter -f -n Socra16 -i 1 Boite.m3u8 Boite
86 items imported
> PlexPlaylistImporter -f -n Socra16 -i 2 Boite.m3u8 Boite
86 items imported

By the way, is it necessary to restart the Plex server to see the added playlists ?

Regards

Antony

@dakusan
Copy link
Owner

dakusan commented Jul 5, 2017

Since you are using a NAS, it's probably a really good idea to restart it, yes.

@lpzantony
Copy link
Author

Ok, I just rebooted the NAS after throwing the commands quoted above, no playlist. I don't want to wast your time on that, I have no clue from where this "bug" may come from.
I let you decide to close the issue if you consider it is not worth your time.

Otherwise I'm ok to try any idea.

@dakusan
Copy link
Owner

dakusan commented Jul 5, 2017

Perhaps try closing plex server before doing the runs, then reopening it. It's possible it is force locking the sqlite file and the NAS isn't allowing another process to modify it.

@lpzantony
Copy link
Author

Good idea but it still successfully output with no result in Plex :/

@ynadji
Copy link

ynadji commented Aug 11, 2017

i have the same issue (runs w/o errors but no playlist is created) with plex server 3.17.3. i've also tried:

  • stopping plex, running the script, starting plex
  • restarting plex after running the script
  • adding a playlist that contains songs that are not using symlinks

is it possible that the DB structure is different in later versions? i'll spend some time digging into this problem later and will report any of my findings. thanks for the script though @dakusan . once we handle this bug i'm going to use it quite a bit :).

@9Mad-Max5
Copy link

9Mad-Max5 commented May 17, 2018

Hello,
I am working on an QNAP TS-231 after I installed a new Python 3.6 with Entware and made hard links to the Plex folder everything seems to work fine. Till it should search in the databse for the same link.

@lpzantony Could you tell me which is the correct code for compare the playlist givin path with the path in the database? I tried every combination for path i now so it seems to be a struggle with the code itself
Just checked with your code but that confuses me pretty much.
FilePath = /share/CACHEDEV1_DATA/.qpkg/NextCloud/nextcloud/data/HMaximilian/files/Musik/Dizzee Rascal/Dizzee Rascal - Bonkers.mp3
File not found in DB: /share/CACHEDEV1_DATA/.qpkg/NextCloud/nextcloud/data/HMaximilian/files/Musik/Dizzee Rascal/Dizzee Rascal - Bonkers.mp3

@ynadji Did you found a solution and are able to import the Playlist?

@9Mad-Max5
Copy link

I just figured it out.
The problem is that the path in the database is correct and the m3u also.
But after the link was feed in like:

/share/CACHEDEV1_DATA/Web/nextcloud/data/HMaximilian/files/Musik/Dizzee Rascal/Dizzee Rascal - Bonkers.mp3

The Importer changes ist like written above.

@dakusan Could it be that Plex don´t recognize the playlist because the plex player don´t reads the Database back and just reads it?

@lpzantony
Copy link
Author

Ok so @9Mad-Max5 you did figured out how to extract Plex's playlists path using the code I shared?

@9Mad-Max5
Copy link

9Mad-Max5 commented May 20, 2018

@lpzantony yes and no.
The code you shared gave me the real path back.
But the Plex database and the playlist uses a little bit changed path.
LookupPath gives the real path back, but there is the issue the databse uses another one.
So i changed it to LineStr that makes the thinks work.
But the Playlist in Plex still do´t get modified.
Maybe the missing created_at time is a Problem.

Ok i just made it.
@lpzantony i could import an Playlist.
To make this happen the Playlist was already existing. So the "created_at" time was already set.
After this is imported with the importer. So i could play all Playlist traks but the title wasn´t shown in the app. To solve this i put a new random trak to the Playlist so a new created_at time will be set. And wcwrything is just fine.

@9Mad-Max5
Copy link

Hi,

luckyli I get everything working for my Enviroment.
But im not able to push it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants