@@ -16,11 +16,11 @@ def main(argv): | |||||
sys.exit() | sys.exit() | ||||
elif opt in ("-i", "--ifile"): | elif opt in ("-i", "--ifile"): | ||||
inputfile = arg | inputfile = arg | ||||
results = YoutubeSearch(inputfile, max_results=10).to_dict() | |||||
ans = 'https://youtu.be/' + results[0]['url_suffix'][9:] | |||||
print(ans) | |||||
elif opt in ("-o", "--ifile"): | |||||
numberfile = arg | |||||
results = YoutubeSearch(inputfile, max_results=int(numberfile)).to_dict() | |||||
ans = 'https://youtu.be/' + results[int(numberfile)-1]['url_suffix'][9:] | |||||
print(ans) | |||||
if __name__ == "__main__": | if __name__ == "__main__": | ||||
main(sys.argv[1:]) | main(sys.argv[1:]) |
@@ -35,4 +35,14 @@ All you have to do is launch spotitube.sh and give it a string argument with the | |||||
./spotitube.sh "Song name" | ./spotitube.sh "Song name" | ||||
``` | ``` | ||||
If you want to get a specific index of a result, just type that index as a second argument: | |||||
```shell | |||||
./spotitube.sh "Song name" 3 | |||||
``` | |||||
This will result in: | |||||
``` | |||||
Searching for result #3 in Song name... | |||||
``` | |||||
Enjoy your music! | Enjoy your music! |
@@ -1,4 +1,5 @@ | |||||
va=$(python3 open.py -i "$1") | |||||
echo $1 | |||||
echo "Searching for result #${2:-1} in $1..." | |||||
va=$(python3 open.py -i "$1" -o "${2:-1}") | |||||
echo "Opening $va" | echo "Opening $va" | ||||
mpv --no-video $va | mpv --no-video $va |