Code Monkey home page Code Monkey logo

Comments (5)

sigma67 avatar sigma67 commented on June 9, 2024

Sounds reasonable, feel free to submit a PR when you get around to it.

Do you think it's possible to make using SpotifyOAuth optional since it involves an extra step?

from spotify_to_ytmusic.

kenjibailly avatar kenjibailly commented on June 9, 2024

Library is great, but doesn't support user's liked Songs. This is because it's currently using the Client Credentials Flow. Turns out you can support user's liked songs with only a few extra steps.

I'll outline here and try put together a PR sometime, it just requires a few changes.

  • Add http://localhost as a redirect URL on Spotify
  • Swap out SpotifyClientCredentials for SpotifyOAuth(client_id=conf['client_id'], client_secret=conf['client_secret'], scope="user-library-read", redirect_uri="http://localhost")
  • When you login, it'll open a browser, ask the user to sign in, then you copy the URL back into console
  • Make a new func like this:
def getSpotifyLikedTracks(self):

        results = []
        playlists = self.api.current_user_saved_tracks(20)
        while playlists:
            for i, playlist in enumerate(playlists['items']):

                result = build_result(playlist);

                results.append(result)

            if playlists['next']:
                playlists = self.api.next(playlists)
            else:
                playlists = None

        return results

Splitting out build_results into:

def build_results(tracks, album=None):
    results = []
    for track in tracks:

        result = build_result(track, album)

        if result is not None:
            results.append(result)

    return results

def build_result(track, album=None):
    if 'track' in track:
        track = track['track']
    
    album_name = album if album else track['album']['name']

    return {
        'artist': ' '.join([artist['name'] for artist in track['artists']]),
        'name': track['name'],
        'album': album_name,
        'duration': track['duration_ms']/1000
    }

And then have a func somewhere in main doing the following:

tracks = Spotify().getSpotifyLikedTracks()
videoIds = ytmusic.search_songs(tracks)
playlist_id = ytmusic.create_playlist("Liked Music", "Liked Music", "PRIVATE", videoIds)

Any idea when you could submit this?
I'm having a few issues

image

from spotify_to_ytmusic.

Hindook avatar Hindook commented on June 9, 2024

Hello friends, any news?

from spotify_to_ytmusic.

sigma67 avatar sigma67 commented on June 9, 2024

I'm open towards somebody submitting an implementation. The SpotifyOAuth should be optional though and only used where relevant (i.e. for all transfer, liked songs).

from spotify_to_ytmusic.

orkonung avatar orkonung commented on June 9, 2024

hi. I opened the spotify application on my pc (windows), then I selected all the liked songs with the Ctrl + A button and added them to a new playlist.

from spotify_to_ytmusic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.