Skip to content

Commit

Permalink
Fix some formatting and update version
Browse files Browse the repository at this point in the history
  • Loading branch information
XDGFX committed Sep 1, 2020
1 parent 8dc2ac3 commit 8c3f462
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
66 changes: 36 additions & 30 deletions PPP.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# --- PPP (Plex Playlist Pusher) ---
# Synchronises playlists between local files (.m3u) and Plex playlists.
# If there are differences between local and Plex playlists, both will be
# merged and duplicates deleted; meaning tracks can be added on one and
# updated on both... but must be deleted on BOTH to remove completely
# (the same goes for new playlists).

# XDGFX 2020

# 17/03/19 Started working on script
# 19/03/19 Original v2.0 Release (where v1.0 was bash version)
# 20/03/19 v2.1 Updated to use tempfile module temporary directory
# 22/03/19 v2.1.1 General improvements and bug fixes
# 23/03/19 v2.1.2 Fixed v2.1 and v2.1.1 releases, no longer using tempfile
# 30/03/19 v2.1.3 Added timestamp and improved character support
# 20/12/19 v3.0.0 MAJOR REWRITE: Added setup procedure and UNIX / Windows compatibility
# 30/12/19 v3.0.1 Added ability to ignore SSL certificates
# 02/01/20 v3.0.2 Fixed prepend conversion when PPP and playlist machine not same type
# 07/01/20 v3.0.3 Touches and tweaks by cjnaz
# 09/01/20 v3.0.4 Fixed custom retention arguments
# 17/04/20 v3.0.5 Improved support for Plex running in containers by gotson

# Uses GNU General Public License

# for hiding SSL warnings when cert checking is disabled
"""
--- PPP (Plex Playlist Pusher) ---
Synchronises playlists between local files (.m3u) and Plex playlists.
If there are differences between local and Plex playlists, both will be
merged and duplicates deleted; meaning tracks can be added on one and
updated on both... but must be deleted on BOTH to remove completely
(the same goes for new playlists).
XDGFX 2020
17/03/19 Started working on script
19/03/19 Original v2.0 Release (where v1.0 was bash version)
20/03/19 v2.1 Updated to use tempfile module temporary directory
22/03/19 v2.1.1 General improvements and bug fixes
23/03/19 v2.1.2 Fixed v2.1 and v2.1.1 releases, no longer using tempfile
30/03/19 v2.1.3 Added timestamp and improved character support
20/12/19 v3.0.0 MAJOR REWRITE: Added setup procedure and UNIX / Windows compatibility
30/12/19 v3.0.1 Added ability to ignore SSL certificates
02/01/20 v3.0.2 Fixed prepend conversion when PPP and playlist machine not same type
07/01/20 v3.0.3 Touches and tweaks by cjnaz
09/01/20 v3.0.4 Fixed custom retention arguments
17/04/20 v3.0.5 Improved support for Plex running in containers by gotson
01/09/20 v3.0.6 General cleanup by pirtoo
Uses GNU General Public License
"""


# --- IMPORT MODULES ---
import warnings
import json # for saving of variables
import re # for verifying input variables
Expand All @@ -38,9 +42,8 @@
from collections import OrderedDict # url ordering
import requests # HTTP POST requests
from datetime import datetime # for timestamp
vers = "v3.0.5"

# --- IMPORT MODULES ---
vers = "v3.0.6"


# --- FUNCTIONS ---
Expand All @@ -62,7 +65,8 @@ def plexGetRequest(url, plex_token, check_ssl):
raise SystemExit

print("ERROR: Request failed.")
print('ERROR: Return code: %d Reason: %s' % (resp.status_code, resp.reason))
print('ERROR: Return code: %d Reason: %s' %
(resp.status_code, resp.reason))
raise SystemExit


Expand Down Expand Up @@ -194,7 +198,8 @@ def setupVariables():

# If we have more than one playlist add the second to get better deta for the prefix
if len(keys) > 1:
_, playlist_extra = plexPlaylist(server_url, plex_token, keys[1], check_ssl)
_, playlist_extra = plexPlaylist(
server_url, plex_token, keys[1], check_ssl)
playlist = playlist + playlist_extra

# Convert from Windows to UNIX paths
Expand Down Expand Up @@ -670,7 +675,8 @@ def stripPrepend(path, prepend, invert):

# If the post failed then print the return code and the reason for failing.
if not resp.ok:
print('ERROR: Return code: %d Reason: %s' % (resp.status_code, resp.reason))
print('ERROR: Return code: %d Reason: %s' %
(resp.status_code, resp.reason))
failed += 1

br()
Expand Down
2 changes: 1 addition & 1 deletion example-variables.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

{
"server_url": "http://192.168.1.100:32400",
"check_ssl": "True",
"plex_token": "A1B3c4bdHA3s8COTaE3l",
Expand Down

0 comments on commit 8c3f462

Please sign in to comment.