Skip to content

Commit

Permalink
Merge pull request #6 from baruch95/python-rewrite
Browse files Browse the repository at this point in the history
Fixed foreign characters
  • Loading branch information
XDGFX authored Mar 30, 2019
2 parents 099f817 + 1c7752a commit 43feafe
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions PPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
print(('Saving Plex playlist: ' + str(title[0]) + '\n'))

# Get each track and save to file
file = open('tmp/plex/' + str(title[0]) + '.m3u', 'w+')
file = io.open('tmp/plex/' + str(title[0]) + '.m3u', 'w+', encoding = 'utf8')

path = dom.getElementsByTagName('Part')
path = [items.attributes['file'].value for items in path] # Extract disk path to music file
Expand All @@ -144,9 +144,9 @@
for filename in os.listdir('tmp/plex/'):
if not os.path.isfile(os.path.join('tmp/local/', filename)):
print(('Found new Plex playlist: ' + filename))
plex_tracks = open(os.path.join('tmp/plex/', filename), 'r').read().splitlines()
plex_tracks = io.open(os.path.join('tmp/plex/', filename), 'r', encoding = 'utf8').read().splitlines()
os.remove(os.path.join('tmp/plex/', filename))
file = open('tmp/merged/' + filename, 'w+')
file = io.open('tmp/merged/' + filename, 'w+', encoding = 'utf8')
for i in range(len(plex_tracks)):
plex_tracks[i] = plex_tracks[i].strip(plex_prepend) # Strips plex_prepend
file.write(plex_tracks[i] + '\n')
Expand All @@ -155,9 +155,9 @@
for filename in os.listdir('tmp/local/'):
if not os.path.isfile(os.path.join('tmp/plex/', filename)):
print(('Found new local playlist: ' + filename))
local_tracks = open(os.path.join('tmp/local/', filename), 'r').read().splitlines()
local_tracks = io.open(os.path.join('tmp/local/', filename), 'r', encoding = 'utf8').read().splitlines()
os.remove(os.path.join('tmp/local/', filename))
file = open('tmp/merged/' + filename, 'w+')
file = io.open('tmp/merged/' + filename, 'w+', encoding = 'utf8')
for i in range(len(local_tracks)):
if not local_tracks[i].startswith('#'): #Skips m3u tags beginning with #
local_tracks[i] = local_tracks[i].strip(local_prepend) # Strips local_prepend
Expand All @@ -169,12 +169,12 @@

print(('Merging: ' + filename))

local_tracks = open(os.path.join('tmp/local/', filename), 'r').read().splitlines()
local_tracks = io.open(os.path.join('tmp/local/', filename), 'r', encoding = 'utf8').read().splitlines()

for i in range(len(local_tracks)): # Strips local_prepend
local_tracks[i] = local_tracks[i].strip(local_prepend)

plex_tracks = open(os.path.join('tmp/plex/', filename), 'r').read().splitlines()
plex_tracks = io.open(os.path.join('tmp/plex/', filename), 'r', encoding = 'utf8').read().splitlines()

for i in range(len(plex_tracks)): # Strips plex_prepend
plex_tracks[i] = plex_tracks[i].strip(plex_prepend)
Expand All @@ -196,7 +196,7 @@

# Copy merged playlists back into tmp/plex/ and tmp/local/ with prepends re-added
for filename in os.listdir('tmp/merged/'):
new_tracks = open(os.path.join('tmp/merged/', filename), 'r+').read().splitlines()
new_tracks = io.open(os.path.join('tmp/merged/', filename), 'r+', encoding = 'utf8').read().splitlines()
plex_tracks = []
local_tracks = []

Expand Down

0 comments on commit 43feafe

Please sign in to comment.