diff --git a/.gitignore b/.gitignore index e69de29..3b1733d 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,5 @@ +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..21d2c03 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,205 @@ +{ + "version": "0.2.0", + "configurations": [ + + { + "name": "Python", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "/home/yash/miniconda3/envs/music-tagger/bin/python3.5", + "program": "${file}", + "cwd": "${workspaceRoot}", + "env": {}, + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "PySpark", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "osx": { + "pythonPath": "${env:SPARK_HOME}/bin/spark-submit" + }, + "windows": { + "pythonPath": "${env:SPARK_HOME}/bin/spark-submit.cmd" + }, + "linux": { + "pythonPath": "${env:SPARK_HOME}/bin/spark-submit" + }, + "program": "${file}", + "cwd": "${workspaceRoot}", + "env": {}, + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Python Module", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "/home/yash/miniconda3/envs/music-tagger/bin/python3.5", + "module": "module.name", + "cwd": "${workspaceRoot}", + "env": {}, + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Integrated Terminal/Console", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "/home/yash/miniconda3/envs/music-tagger/bin/python3.5", + "program": "${file}", + "cwd": "", + "console": "integratedTerminal", + "env": {}, + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit" + ] + }, + { + "name": "External Terminal/Console", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "/home/yash/miniconda3/envs/music-tagger/bin/python3.5", + "program": "${file}", + "cwd": "", + "console": "externalTerminal", + "env": {}, + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit" + ] + }, + { + "name": "Django", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "${config:python.pythonPath}", + "program": "${workspaceRoot}/manage.py", + "cwd": "${workspaceRoot}", + "args": [ + "runserver", + "--noreload" + ], + "env": {}, + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput", + "DjangoDebugging" + ] + }, + { + "name": "Flask", + "type": "python", + "request": "launch", + "stopOnEntry": false, + "pythonPath": "${config:python.pythonPath}", + "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter", + "cwd": "${workspaceRoot}", + "env": { + "FLASK_APP": "${workspaceRoot}/quickstart/app.py" + }, + "args": [ + "run", + "--no-debugger", + "--no-reload" + ], + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Flask (old)", + "type": "python", + "request": "launch", + "stopOnEntry": false, + "pythonPath": "${config:python.pythonPath}", + "program": "${workspaceRoot}/run.py", + "cwd": "${workspaceRoot}", + "args": [], + "env": {}, + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Pyramid", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "${config:python.pythonPath}", + "cwd": "${workspaceRoot}", + "env": {}, + "envFile": "${workspaceRoot}/.env", + "args": [ + "${workspaceRoot}/development.ini" + ], + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput", + "Pyramid" + ] + }, + { + "name": "Watson", + "type": "python", + "request": "launch", + "stopOnEntry": true, + "pythonPath": "${config:python.pythonPath}", + "program": "${workspaceRoot}/console.py", + "cwd": "${workspaceRoot}", + "args": [ + "dev", + "runserver", + "--noreload=True" + ], + "env": {}, + "envFile": "${workspaceRoot}/.env", + "debugOptions": [ + "WaitOnAbnormalExit", + "WaitOnNormalExit", + "RedirectOutput" + ] + }, + { + "name": "Attach (Remote Debug)", + "type": "python", + "request": "attach", + "localRoot": "${workspaceRoot}", + "remoteRoot": "${workspaceRoot}", + "port": 3000, + "secret": "my_secret", + "host": "localhost" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..d5dad07 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.linting.pylintEnabled": true, + "python.formatting.provider": "autopep8" +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..a0ba79a --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,7 @@ +{ + "version": "0.1.0", + "command": "/home/yash/miniconda3/envs/music-tagger/bin/python3.5", + "isShellCommand": true, + "args": ["${file}"], + "showOutput": "always" +} \ No newline at end of file diff --git a/addMetadata.py b/addMetadata.py new file mode 100644 index 0000000..d4f86b8 --- /dev/null +++ b/addMetadata.py @@ -0,0 +1,51 @@ +import musicbrainzngs as m +import sys + + +def show_release_details(rel): + + if rel['title'] != 'Half Girlfriend': + return + + """Print some details about a release dictionary to stdout. + """ + # "artist-credit-phrase" is a flat string of the credited artists + # joined with " + " or whatever is given by the server. + # You can also work with the "artist-credit" list manually. + + print("{}, by {}".format(rel['title'], rel["artist-credit-phrase"])) + if 'date' in rel: + print("Released {} ({})".format(rel['date'], rel['status'])) + print("MusicBrainz ID: {}".format(rel['id'])) + + +def main(): + m.set_useragent( + "RepairMusicMetadata", "0.1", "https://yashagarwal.me") + # print(m.get_label_by_id("aab2e720-bdd2-4565-afc2-460743585f16")) + + result = m.search_releases(release='Half Girlfriend', + limit=5) + + p = m.search_releases("Raabta") + print(p) + # if not result['release-list']: + # sys.exit("no release found") + # for (idx, release) in enumerate(result['release-list']): + # print("match #{}:".format(idx + 1)) + # release_id = release['id'] + # # type(release_id) + # print(release) + # data = m.get_image_list(release_id) + + # print(data) + # for image in data["images"]: + # if "Front" in image["types"] and image["approved"]: + # print("%s is an approved front image!" % + # image["thumbnails"]["large"]) + # break + # print() + + +if __name__ == "__main__": + main() diff --git a/data.json b/data.json new file mode 100644 index 0000000..8f5e2b2 --- /dev/null +++ b/data.json @@ -0,0 +1,109 @@ +{ + 'release-group':{ + 'type':'Soundtrack', + 'primary-type':'Album', + 'id':'90a8152a-29aa-440a-a783-faf8bf435be3', + 'secondary-type-list':[ + 'Soundtrack' + ] + }, + 'medium-list':[ + { + 'track-list':[ + + ], + 'track-count':11, + 'disc-list':[ + + ], + 'format':'Digital Media', + 'disc-count':0 + } + ], + 'country':'IN', + 'barcode':'', + 'packaging':'None', + 'id':'2036808f-d484-4d00-b8f3-819e344bb131', + 'artist-credit':[ + { + 'artist':{ + 'name':'Mithoon', + 'id':'7f74ac10-e2f0-480a-be9b-82264d2078a9', + 'disambiguation':'Indian composer and playback singer', + 'sort-name':'Mithoon' + } + }, + '/', + { + 'artist':{ + 'name':'Tanishk Bagchi', + 'id':'2eeb1326-b91e-470f-b210-d07b54f5334a', + 'sort-name':'Bagchi, Tanishk' + } + }, + '/', + { + 'artist':{ + 'name':'Rishi Rich', + 'id':'9b52b90b-9858-4463-b20d-7e00480c4714', + 'sort-name':'Rishi Rich' + } + }, + '/', + { + 'artist':{ + 'name':'Farhan Saeed', + 'id':'78af11d1-d351-4229-ad79-1112068cb1ab', + 'sort-name':'Saeed, Farhan' + } + }, + '/', + { + 'artist':{ + 'name':'Ami Mishra', + 'id':'cf9f2995-3a44-4bf3-b4e5-7847c68be644', + 'sort-name':'Mishra, Ami' + } + }, + '/', + { + 'artist':{ + 'name':'Rahul Mishra', + 'id':'9202f366-c50d-48b6-a069-47f24b26a3d1', + 'sort-name':'Rahul Mishra' + } + } + ], + 'release-event-list':[ + { + 'area':{ + 'name':'India', + 'iso-3166-1-code-list':[ + 'IN' + ], + 'id':'d31a9a15-537f-3669-ad53-25753ddd2772', + 'sort-name':'India' + }, + 'date':'2017-04-28' + } + ], + 'ext:score':'100', + 'text-representation':{ + 'language':'eng', + 'script':'Latn' + }, + 'date':'2017-04-28', + 'medium-count':1, + 'artist-credit-phrase':'Mithoon/Tanishk Bagchi/Rishi Rich/Farhan Saeed/Ami Mishra/Rahul Mishra', + 'title':'Half Girlfriend', + 'label-info-list':[ + { + 'label':{ + 'name':'Zee Music', + 'id':'b0d52317-46e4-4208-98f3-926f1a67397b' + } + } + ], + 'medium-track-count':11, + 'status':'Official' +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b35c9bc..6762ec1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,6 +5,7 @@ certifi==2017.4.17 chardet==3.0.4 eyeD3==0.8 idna==2.5 +musicbrainzngs==0.6 musictools==2.1.4 mutagen==1.38 packaging==16.8