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

Fixed foreign characters #6

Merged
merged 2 commits into from
Mar 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions PPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,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 @@ -141,9 +141,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 @@ -152,9 +152,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 @@ -166,12 +166,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 @@ -193,7 +193,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