{"id":21561577,"url":"https://github.com/ztshia/spotify-autosync","last_synced_at":"2025-03-18T04:46:46.791Z","repository":{"id":247035825,"uuid":"824862774","full_name":"ztshia/spotify-autosync","owner":"ztshia","description":"spotify点赞歌曲、歌单自动同步","archived":false,"fork":false,"pushed_at":"2024-10-24T10:27:16.000Z","size":47844,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-25T07:49:53.977Z","etag":null,"topics":["autosync","liked-songs","playlist","spotify"],"latest_commit_sha":null,"homepage":"https://playlist.upstairs.cn","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ztshia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-06T06:43:34.000Z","updated_at":"2024-10-24T10:27:20.000Z","dependencies_parsed_at":"2024-07-07T17:12:54.449Z","dependency_job_id":"21d8a2a6-fedc-45ac-a6ff-8280129d02e9","html_url":"https://github.com/ztshia/spotify-autosync","commit_stats":null,"previous_names":["ztshia/spotify","ztshia/spotify-autosync"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztshia%2Fspotify-autosync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztshia%2Fspotify-autosync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztshia%2Fspotify-autosync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ztshia%2Fspotify-autosync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ztshia","download_url":"https://codeload.github.com/ztshia/spotify-autosync/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244159990,"owners_count":20408019,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autosync","liked-songs","playlist","spotify"],"created_at":"2024-11-24T09:27:12.377Z","updated_at":"2025-03-18T04:46:46.770Z","avatar_url":"https://github.com/ztshia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### 功能简介\n\n自动同步Spotify已点赞的歌曲和指定歌单，生成json文件。\n\n### 使用步骤\n\n1.Fork本项目，删除根目录的所有Json文件。\n\n2.注册[Spotify开发者](https://developer.spotify.com/dashboard/)账号并创建一个应用。访问Spotify开发者网站。\n  登录后，创建一个新应用，获取客户端ID（**Client ID**）和客户端密钥（**Client Secret**）。\n  \n3.访问 https://accounts.spotify.com/authorize?client_id=your_client_id\u0026response_type=code\u0026redirect_uri=your_redirect_uri\u0026scope=user-library-read (更换为你刚才获取的Client ID与填写的redirect_uri)，获取到**auth code**。\n\n4.本地运行以下脚本，获得Refresh Token\n\n```\nimport requests\nimport base64\n\nCLIENT_ID = '**your_client_id**'\nCLIENT_SECRET = '**your_client_secret**'\nREDIRECT_URI = '**your_redirect_uri**'\nAUTH_CODE = '**your_authorization_code**'  # 替换为你获取的授权码\n\ndef get_tokens(auth_code):\n    token_url = 'https://accounts.spotify.com/api/token'\n    headers = {\n        'Authorization': f'Basic {base64.b64encode((CLIENT_ID + \":\" + CLIENT_SECRET).encode()).decode()}',\n    }\n    data = {\n        'grant_type': 'authorization_code',\n        'code': auth_code,\n        'redirect_uri': REDIRECT_URI,\n    }\n    response = requests.post(token_url, headers=headers, data=data)\n    return response.json()\n\ntokens = get_tokens(AUTH_CODE)\nprint(tokens)  # 这将包含 access_token 和 refresh_token\n\n```\n\n5.从脚本返回的数据中得到refresh_token，并填写到GitHub Secrets中：\n\n- 进入你的GitHub仓库。\n- 导航到 \"Settings\" -\u003e \"Secrets and variables\" -\u003e \"Actions\"。\n- 点击 \"New repository secret\"，然后添加以下Secrets：\n  - SPOTIFY_CLIENT_ID\n  - SPOTIFY_CLIENT_SECRET\n  - SPOTIFY_REDIRECT_URI\n  - SPOTIFY_REFRESH_TOKEN（从上面的代码中获取）\n \n6.完成\n\n---\n\n\n### Function Introduction\nAutomatically sync Spotify likes songs with the specified song list to generate a json file.\n\n### Steps\n\n1. Fork this project and delete all Json files in the root directory.\n\n2. Sign up for a Spotify developer account and create an app. Visit the Spotify developer website. After logging in, create a new application and obtain the client ID and client secret.\n   \n3. Visit https://accounts.spotify.com/authorize? client_id=your_client_id\u0026response_type=code\u0026redirect_uri=your_redirect_uri\u0026scope=user-library-read  (Replace with the Client ID you just obtained and the redirect_uri you filled in) to get the auth code.\n\n4. Run the following script locally to obtain the Refresh Token\n\n```\nimport requests\nimport base64\nCLIENT_ID = '**your_client_id**'\nCLIENT_SECRET = '**your_client_secret**'\nREDIRECT_URI = '**your_redirect_uri**'\nAUTH_CODE = '**your_authorization_code**' #Replace with the authorization code you obtained\n\ndef get_tokens(auth_code):\n    token_url = 'https://accounts.spotify.com/api/token'\n    headers = {\n        'Authorization': f'Basic {base64.b64encode((CLIENT_ID + \":\" + CLIENT_SECRET).encode()).decode()}',\n    }\n    data = {\n        'grant_type': 'authorization_code',\n        'code': auth_code,\n        'redirect_uri': REDIRECT_URI,\n    }\n    response = requests.post(token_url, headers=headers, data=data)\n    return response.json()\n\ntokens = get_tokens(AUTH_CODE)\nprint(tokens) #This will include access_token and refresh_token\n\n```\n\n5. Get refresh_token from the data returned by the script and fill it in GitHub Secrets:\n- Go to your GitHub repository.\n- Navigate to \"Settings\" -\u003e \"Secrets and variables\" -\u003e \"Actions\".\n- Click \"New repository secret\" and add the following Secrets:\n  - SPOTIFY_CLIENT_ID\n  - SPOTIFY_CLIENT_SECRET\n  - SPOTIFY_REDIRECT_URI\n  - SPOTIFY_REFRESH_TOKEN (obtained from the code above)\n\n6. Completed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fztshia%2Fspotify-autosync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fztshia%2Fspotify-autosync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fztshia%2Fspotify-autosync/lists"}