Easy pick artist code, python (New and improved)


SUBMITTED BY: Guest

DATE: Nov. 29, 2013, 3:32 p.m.

FORMAT: Text only

SIZE: 3.8 kB

HITS: 838

  1. # This program will pick an artist from a list of artists in a .txt file
  2. # You have to have the text file in the same place this code is in
  3. # In the text file, it's one artist per line
  4. # After it picks the artist, it asks if you want to open the artist page
  5. # on last.fm. If you say 'n', it skips the piratebay and youtube search
  6. # and asks if you want to pick another artist. If not, you type 'end'.
  7. # If you do open the artist page, it asks if you want to search an album
  8. # on piratebay and search a song on youtube.
  9. # !!!IMPORTANT!!!
  10. # BE SURE TO HAVE A BROWSER ALREADY OPEN, ELSE IT WILL OPEN NEW WINDOWS
  11. # Python version, 3.x
  12. import random
  13. import time
  14. import webbrowser
  15. import urllib.parse
  16. import subprocess
  17. musicChecked = 0
  18. # These are optional and can be taken out
  19. openss = input('Is SoulSeek open? >> ')
  20. if openss == 'y':
  21. print('Ok, going on.')
  22. pass
  23. elif openss == 'n':
  24. openss1 = input('Do you want to open SoulSeek? >> ')
  25. if openss1 == 'y':
  26. print("Opening SoulSeek...")
  27. time.sleep(1.5)
  28. subprocess.Popen(r"C:\Program Files (x86)\SoulseekQt\SoulseekQt.exe")
  29. elif openss1 == 'n':
  30. print('Ok, going on.')
  31. pass
  32. openutor = input('Is µTorrent open? >> ')
  33. if openutor == 'y':
  34. print('Ok, going on.')
  35. pass
  36. elif openutor == 'n':
  37. openutor1 = input('Do you want to open µTorrent? >> ')
  38. if openutor1 == 'y':
  39. print("Opening µTorrent...")
  40. time.sleep(1.5)
  41. # Where it says '[User]' enter your username
  42. subprocess.Popen(r"C:\Users\[User]\AppData\Roaming\uTorrent\uTorrent.exe")
  43. elif openutor1 == 'n':
  44. print('Ok, going on.')
  45. pass
  46. time.sleep(1)
  47. while True:
  48. print("\n")
  49. file = open('a.txt', 'r')
  50. line = random.choice(file.readlines())
  51. print("----------------------------------------------")
  52. print("Band/Artist: ", line)
  53. musicChecked = musicChecked + 1
  54. print("You checked out " + str(musicChecked) + " band(s)/artist(s)")
  55. openpage = input('\nWant to open the artist page on last.fm? >> ')
  56. if openpage == 'y':
  57. url = urllib.parse.urljoin('http://www.last.fm/music/',line)
  58. elif openpage == 'n':
  59. pass
  60. if openpage == 'y':
  61. print('\nOpening last.fm page... ')
  62. webbrowser.open(url)
  63. time.sleep(1)
  64. openalbum = input('\nSearch album on piratebay? >> ')
  65. if openalbum == 'y':
  66. nameofalb = input('Name of album >> ')
  67. url3 = urllib.parse.urljoin('http://www.thepiratebay.sx/search/',nameofalb + ' ' + line)
  68. print('Opening thepiratebay page... ')
  69. webbrowser.open(url3)
  70. searchyt = input('\nSearch for a song on youtube? >> ')
  71. if searchyt == 'y':
  72. nameofsng = input('Name of song >> ')
  73. url4 = urllib.parse.urljoin('http://www.youtube.com/','results?search_query=' + nameofsng + ' ' + line + '&sm=3')
  74. print('Opening search on youtube... ')
  75. webbrowser.open(url4)
  76. elif openalbum == 'n':
  77. pass
  78. elif searchyt== 'n':
  79. pass
  80. time.sleep(.5)
  81. again = input("\nAgain? >> ")
  82. print("----------------------------------------------")
  83. if again == "end":
  84. print("ok")
  85. break

comments powered by Disqus