Skip to content

Commit

Permalink
Release v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekmj303 committed Jul 17, 2024
1 parent a52dce6 commit 30c4dc9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
15 changes: 7 additions & 8 deletions ytm2spt.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,14 +318,9 @@ def run_command(self):
create_new = self.create_new_checkbox.isChecked()
limit = self.limit_input.value() if self.limit_input.value() > 0 else None

os.environ["SPOTIFY_USER_ID"] = SETTINGS.value("SPOTIFY_USER_ID")
os.environ["SPOTIFY_CLIENT_ID"] = SETTINGS.value("SPOTIFY_CLIENT_ID")
os.environ["SPOTIFY_CLIENT_SECRET"] = SETTINGS.value("SPOTIFY_CLIENT_SECRET")
os.environ["SPOTIFY_REDIRECT_URI"] = SETTINGS.value("SPOTIFY_REDIRECT_URI")

# Run ytm2spt
self.worker = RunCommandWorker(youtube_arg, spotify_arg, spotify_playlist_name, youtube_oauth, dry_run, create_new, limit)
self.worker.finished.connect(self.run_finished)
self.worker.completed.connect(self.run_finished)
self.worker.error.connect(self.run_error)
self.worker.start()

Expand Down Expand Up @@ -355,7 +350,7 @@ def yt_private_toggled(self):


class RunCommandWorker(QThread):
finished = Signal()
completed = Signal()
error = Signal(str)

def __init__(self, youtube_arg, spotify_arg, spotify_playlist_name, youtube_oauth, dry_run, create_new, limit):
Expand All @@ -370,8 +365,12 @@ def __init__(self, youtube_arg, spotify_arg, spotify_playlist_name, youtube_oaut

def run(self):
try:
os.environ["SPOTIFY_USER_ID"] = SETTINGS.value("SPOTIFY_USER_ID")
os.environ["SPOTIFY_CLIENT_ID"] = SETTINGS.value("SPOTIFY_CLIENT_ID")
os.environ["SPOTIFY_CLIENT_SECRET"] = SETTINGS.value("SPOTIFY_CLIENT_SECRET")
os.environ["SPOTIFY_REDIRECT_URI"] = SETTINGS.value("SPOTIFY_REDIRECT_URI")
ytm2spt.main(self.youtube_arg, self.spotify_arg, self.spotify_playlist_name, self.youtube_oauth, self.dry_run, self.create_new, self.limit)
self.finished.emit()
self.completed.emit()
except Exception as e:
print(e)
print(traceback.format_exc())
Expand Down
2 changes: 2 additions & 0 deletions ytm2spt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def main(youtube_arg, spotify_arg, spotify_playlist_name, youtube_oauth, dryrun,
if dryrun:
ytm2spt_logger.info("Dryrun mode enabled. No songs will be added to Spotify.")
else:
if not (spotify_arg or spotify_playlist_name):
spotify_playlist_name = yt.get_playlist_title()
spotify_id = get_spotify_playlist_id(spotify_arg, spotify_playlist_name, create_new, dryrun)
ytm2spt_logger.info(f"Spotify Playlist ID: {spotify_id}")
sp.set_playlist_id(spotify_id)
Expand Down
8 changes: 4 additions & 4 deletions ytm2spt/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ def generate_description() -> str:

class Spotify:
def __init__(self):
self.user_id = os.getenv('SPOTIFY_USER_ID')
self.user_id = os.environ["SPOTIFY_USER_ID"]
self.spotify = spotipy.Spotify(auth_manager=SpotifyOAuth(
client_id=os.getenv('SPOTIFY_CLIENT_ID'),
client_secret=os.getenv('SPOTIFY_CLIENT_SECRET'),
redirect_uri=os.getenv('SPOTIFY_REDIRECT_URI'),
client_id=os.environ['SPOTIFY_CLIENT_ID'],
client_secret=os.environ['SPOTIFY_CLIENT_SECRET'],
redirect_uri=os.environ['SPOTIFY_REDIRECT_URI'],
scope='playlist-read-collaborative playlist-modify-private playlist-modify-public playlist-read-private ugc-image-upload'
))
self.playlist_id = ""
Expand Down

0 comments on commit 30c4dc9

Please sign in to comment.