Advertisement
Guest User

plugin.audio.jango/default.py

a guest
Apr 13th, 2017
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 41.99 KB | None | 0 0
  1. import urllib,urllib2,re,xbmcplugin,xbmcgui,os
  2. import cookielib
  3. from helpers import clean_file_name
  4. import settings, time
  5. import glob
  6. import shutil
  7. from t0mm0.common.net import Net
  8. from threading import Thread
  9. import json
  10. import requests
  11. import cookielib
  12. cookie_jar = settings.cookie_jar()
  13.  
  14. net = Net()
  15. ADDON = settings.addon()
  16. ACTIVEPL = settings.current_playlist()
  17. JACCOUNT = settings.jango_account()
  18. USER=settings.username()
  19. PW=settings.password()
  20. fanart = xbmc.translatePath(os.path.join('special://home/addons/plugin.audio.jango',  'fanart.jpg'))
  21. art = xbmc.translatePath(os.path.join('special://home/addons/plugin.audio.jango',  'art')) + '/'
  22. audio_fanart = ""
  23. iconart = xbmc.translatePath(os.path.join('special://home/addons/plugin.audio.jango/art',  'icon_generic.jpg'))
  24. dialog = xbmcgui.Dialog()
  25.  
  26.  
  27. def login(url):
  28.     if not JACCOUNT:
  29.         f = open(cookie_jar, 'w')
  30.         f.close()
  31.     net.set_cookies(cookie_jar)
  32.     link = net.http_GET('http://www.jango.com/').content.encode("utf-8").replace('\n','')
  33.     net.save_cookies(cookie_jar)
  34.     try:contenttime=regex_from_to(link,'updated_time" content="','"')
  35.     except:contenttime=str(int(round(time.time() * 1000)))
  36.     try:sid=regex_from_to(link,'jm.session_id                  = "','"')
  37.     except:sid='na'
  38.     token=regex_from_to(link,'name="csrf-param" /><meta content="','"')
  39.     try:userid=regex_from_to(link,'<a href="/profiles/','"')
  40.     except:userid='na'
  41.     xbmcgui.Window(10000).setProperty("user_id", userid)
  42.     xbmcgui.Window(10000).setProperty("contenttime", contenttime)
  43.     xbmcgui.Window(10000).setProperty("sid", sid)
  44.     xbmcgui.Window(10000).setProperty("token", token)
  45.     if len(userid)<4 and JACCOUNT:
  46.         try:   
  47.             headers = {'Host': 'www.jango.com', 'Referer': 'http://www.jango.com/'}
  48.             payload = {'authenticity_token': token, 'round_this_login_btn': '', 'user[email]': USER, 'user[password]': PW}
  49.             net.set_cookies(cookie_jar)
  50.             link = net.http_POST(url,headers=headers,form_data=payload).content.encode("utf-8").replace('\n','')
  51.             net.save_cookies(cookie_jar)
  52.             try: userid=regex_from_to(link,'a href="/profiles/','"')
  53.             except:userid='na'
  54.             xbmcgui.Window(10000).clearProperty("user_id")
  55.             xbmcgui.Window(10000).setProperty("user_id", userid)
  56.         except:
  57.             pass
  58.  
  59. def login2():
  60.     ADDON.setSetting('jango_account', 'true')
  61.     login('https://www.jango.com/splogin')
  62.     xbmc.executebuiltin("Container.Refresh")
  63.  
  64. def CATEGORIES():
  65.     userid=xbmcgui.Window(10000).getProperty("user_id")
  66.     if len(userid)<4:
  67.         if len(USER)>4 and len(PW)>3:
  68.             addDirAudio('Login','https://www.jango.com/splogin',9998,iconart,'','','','','')
  69.     addDir('Browse Music','http://www.jango.com/browse_music',2,art + 'icon_browse_music.jpg','','')
  70.     if len(userid)>4:
  71.         addDir('Station History','url',9951,art + 'icon_station_history.jpg','1','')
  72.         addDir('Song History','http://www.jango.com/my_song_history',9952,art + 'icon_song_history.jpg','1','')
  73.         addDir('Favourite Songs','http://www.jango.com/song_ratings/favorites',9950,art + 'icon_favourite_songs.jpg','1','')
  74.         addDir('Banned Songs','http://www.jango.com/song_ratings/bans',9950,art + 'icon_banned_songs.jpg','1','')
  75.     addDir('Search Artists','url',24,art + 'icon_search_artists.jpg','','')
  76.     addDir('Search Songs','url',24,art + 'icon_search_songs.jpg','','')
  77.  
  78. def music_sections(name, url):
  79.     headers = {'Host': 'www.jango.com', 'Referer': 'http://www.jango.com/browse_music', 'X-XHR-Referer': 'http://www.jango.com/browse_music'}    
  80.     net.set_cookies(cookie_jar)
  81.     link = net.http_GET(url).content.replace('\n','')
  82.     net.save_cookies(cookie_jar)
  83.     token=xbmcgui.Window(10000).getProperty("token")
  84.     match=re.compile('<li id="(.+?)" class="(.+?)"><a data-no-turbolink href="(.+?)" data-genre-category="(.+?)" title="(.+?)">(.+?)</a></li>').findall(link)
  85.     addDir("Suggestions",'http://www.jango.com/stations/genre_category?gcid=suggestions&_=1445381979609',3,iconart,token,'')
  86.     addDir("Recent Stations",'http://www.jango.com/stations/genre_category?gcid=recent&_=1445381979609',3,iconart,token,'')
  87.     for d1,cl,url,cat,title,title2 in match:
  88.         id = url.replace('/browse_music?gcid=','')
  89.         url='http://www.jango.com/stations/genre_category?gcid=%s' % id
  90.         addDir(clean_file_name(title, use_blanks=False),url,3,iconart,token,'')
  91.        
  92. def sub_sections(name, url, token):
  93.     url=url.replace(' ','+')
  94.     curr_time=int(round(time.time() * 1000))
  95.     url="%s&_=%s" % (url,curr_time)
  96.     headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/browse_music','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept': '*/*', 'X-CSRF-Token': token}
  97.     net.set_cookies(cookie_jar)
  98.     link = net.http_GET(url, headers=headers).content.encode("utf-8").replace('\n','').replace("'",'"')
  99.     net.save_cookies(cookie_jar)
  100.     all_sub=regex_get_all(link,'<div class="genre_station','<hr class="list_divider"/>')
  101.     for a in all_sub:
  102.         title=regex_from_to(a,'play"></span></span>','</a>')
  103.         stid=regex_from_to(a,'href="/stations/','/')
  104.         url='http://www.jango.com/stations/%s/tunein' % stid
  105.         iconimage='http:' + regex_from_to(a,'data-original="','"').replace('_sm','_lg')
  106.         addDir(clean_file_name(title, use_blanks=False),url,10,iconimage,token,stid)
  107.  
  108. def search(name, url):
  109.     keyboard = xbmc.Keyboard('', name, False)
  110.     keyboard.doModal()
  111.     if keyboard.isConfirmed():
  112.         query = keyboard.getText()
  113.         if len(query) > 0:
  114.             if name == 'Search Artists':
  115.                 search_artists(query)
  116.             elif name == 'Search Songs':
  117.                 search_songs(query)
  118.                
  119. def search_artists(query):
  120.     curr_time=int(round(time.time() * 1000))
  121.     token=xbmcgui.Window(10000).getProperty("token")
  122.     headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-CSRF-Token': token, 'X-Requested-With': 'XMLHttpRequest'}
  123.     url = 'http://www.jango.com/artists/jsearch?term=%s&cb=play&source=header&_=%s' % (urllib.quote_plus(query),str(curr_time))
  124.     net.set_cookies(cookie_jar)
  125.     link = net.http_GET(url,headers=headers).content.encode("utf-8").replace('\n','')
  126.     net.save_cookies(cookie_jar)
  127.     match=re.compile('{"label":"(.+?)","value":"(.+?)","id":(.+?),"url":"(.+?)","station_id":(.+?)}').findall(link)
  128.     for label,value,id,url,stid in match:
  129.         url='http://www.jango.com' + url
  130.         addDir(clean_file_name(value, use_blanks=False),url,10,iconart,token,stid)
  131.        
  132. def search_songs(query):
  133.     curr_time=int(round(time.time() * 1000))
  134.     token=xbmcgui.Window(10000).getProperty("token")
  135.     headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-CSRF-Token': token, 'X-Requested-With': 'XMLHttpRequest'}
  136.     url = 'http://www.jango.com/artists/search?search=%s&search_type=song' % (urllib.quote_plus(query))
  137.     net.set_cookies(cookie_jar)
  138.     link = net.http_GET(url,headers=headers).content.encode("utf-8").replace('\n','')
  139.     net.save_cookies(cookie_jar)
  140.     songs=regex_get_all(link,'<li class="song_li artist_song_li">','</li>')
  141.     for s in songs:
  142.         artist=regex_from_to(s,'class="block">','</a>')
  143.         try:
  144.             songname=regex_from_to(s,'title="Play ','"').replace(' Now!','')#video_id&quot;:&quot;
  145.             vurl=regex_from_to(s,'video_id&quot;:&quot;','&quot')
  146.             songid=regex_from_to(s,'trid&quot;:',',')
  147.         except:
  148.             songname=regex_from_to(s,'<div class="song_name" >','</div>').strip()
  149.             vurl="NA"
  150.             try:
  151.                 songid=regex_from_to(s,'song_id=','"')
  152.             except:songid="na"
  153.         iconimage='https://i.ytimg.com/vi/%s/mqdefault.jpg' % vurl
  154.         url='plugin://plugin.video.youtube/play/?video_id=' + vurl
  155.         title="%s - %s" % (artist,songname)
  156.         if songid!="na":
  157.             if vurl=="NA":
  158.                 addDirAudio(clean_file_name(title, use_blanks=False) + " (audio)",songid,13,iconimage,songname,artist,'na','na',vurl)
  159.             else:
  160.                 addDirAudio(clean_file_name(title, use_blanks=False) + " (video)",url,12,iconimage,songname,artist,'na','na',vurl)
  161.        
  162. def favourite_tracks(name,url,page):
  163.     if 'Banned' in name:
  164.         tt='ban'
  165.         url='http://www.jango.com/song_ratings/bans?page=%s' % page
  166.     else:
  167.         tt='fav'
  168.         url='http://www.jango.com/song_ratings/favorites?page=%s' % page
  169.    
  170.     nextpage=int(page)+1
  171.     refurl='http://www.jango.com/profiles/%s?ft=1' % xbmcgui.Window(10000).getProperty("user_id")  
  172.     headers = {'Host': 'www.jango.com', 'Referer': refurl, 'X-XHR-Referer': refurl}
  173.     net.set_cookies(cookie_jar)
  174.     link = net.http_GET(url, headers=headers).content.encode("utf-8").rstrip()
  175.     net.save_cookies(cookie_jar)
  176.     if tt=='ban':
  177.         songs=regex_get_all(link,'<li id="ban','</li>')
  178.     else:
  179.         songs=regex_get_all(link,'<li id="fav','</li>')
  180.     for s in songs:
  181.         artist=regex_from_to(s,'class="block">','</a>')
  182.         try:
  183.             songname=regex_from_to(s,'title="Play ','"').replace(' Now!','')#video_id&quot;:&quot;
  184.             vurl=regex_from_to(s,'video_id&quot;:&quot;','&quot')
  185.             songid=regex_from_to(s,'song_id=','"')
  186.         except:
  187.             songname=regex_from_to(s,'<div class="song_name" >','</div>').strip()
  188.             vurl="NA"
  189.             try:
  190.                 songid=regex_from_to(s,'song_id=','"')
  191.             except:songid="na"
  192.         iconimage='https://i.ytimg.com/vi/%s/mqdefault.jpg' % vurl
  193.         url='plugin://plugin.video.youtube/play/?video_id=' + vurl
  194.         title="%s - %s" % (artist,songname)
  195.         if songid!="na":
  196.             if vurl=="NA":
  197.                 addDirAudio(clean_file_name(title, use_blanks=False) + " (audio)",songid,13,iconimage,songname,artist,songid,tt,vurl)
  198.             else:
  199.                 addDirAudio(clean_file_name(title, use_blanks=False) + " (video)",url,12,iconimage,songname,artist,songid,tt,vurl)
  200.     addDir('Next page - '+name,'url',9950,art + 'topalbums.jpg',str(nextpage),'')
  201.    
  202. def station_history(page):
  203.     nextpage=int(page)+1
  204.     refurl='http://www.jango.com/users/%s/stations?page=%s' % (xbmcgui.Window(10000).getProperty("user_id"),page)
  205.     headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/song_ratings/favorites','X-XHR-Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': 'text/html, application/xhtml+xml, application/xml', 'X-Requested-With': 'XMLHttpRequest'}
  206.     net.set_cookies(cookie_jar)
  207.     link = net.http_GET(refurl,headers=headers).content.encode("utf-8").replace('\n','').replace("'",'"')
  208.     net.save_cookies(cookie_jar)
  209.     token=xbmcgui.Window(10000).getProperty("token")
  210.     all_sub=regex_get_all(link,'<div class="genre_station','<hr class="list_divider"/>')
  211.     for a in all_sub:
  212.         title=regex_from_to(a,'play"></span></span>','</a>')
  213.         stid=regex_from_to(a,'href="/stations/','/')
  214.         url='http://www.jango.com/stations/%s/tunein' % stid
  215.         iconimage='http:' + regex_from_to(a,'data-original="','"').replace('_sm','_lg')
  216.         addDir(clean_file_name(title, use_blanks=False),url,10,iconimage,token,stid)
  217.     addDir('Next page','url',9951,art + 'icon_next_page.jpg',str(nextpage),'')
  218.        
  219. def song_history(url,page):
  220.     nextpage=int(page)+1
  221.     url='http://www.jango.com/users/%s/full_history?page=%s' % (xbmcgui.Window(10000).getProperty("user_id"),page)
  222.     headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/song_ratings/favorites','X-XHR-Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': 'text/html, application/xhtml+xml, application/xml', 'X-Requested-With': 'XMLHttpRequest'}
  223.     net.set_cookies(cookie_jar)
  224.     link = net.http_GET(url,headers=headers).content.encode("utf-8").replace('\n','').replace("'",'"')
  225.     net.save_cookies(cookie_jar)
  226.     songs=regex_get_all(link,'<li class="song_li artist_song_li">','</li>')
  227.     for s in songs:
  228.         artist=regex_from_to(s,'class="block">','</a>')
  229.         try:
  230.             songname=regex_from_to(s,'title="Play ','"').replace(' Now!','')#video_id&quot;:&quot;
  231.             vurl=regex_from_to(s,'video_id&quot;:&quot;','&quot')
  232.             songid=regex_from_to(s,'trid&quot;:',',')
  233.         except:
  234.             songname=regex_from_to(s,'<div class="song_name" >','</div>').strip()
  235.             vurl="NA"
  236.             try:
  237.                 songid=regex_from_to(s,'song_id=','"')
  238.             except:songid="na"
  239.         iconimage='https://i.ytimg.com/vi/%s/mqdefault.jpg' % vurl
  240.         url='plugin://plugin.video.youtube/play/?video_id=' + vurl
  241.         title="%s - %s" % (artist,songname)
  242.         if songid!="na":
  243.             if vurl=="NA":
  244.                 addDirAudio(clean_file_name(title, use_blanks=False) + " (audio)",songid,13,iconimage,songname,artist,'na','na',vurl)
  245.             else:
  246.                 addDirAudio(clean_file_name(title, use_blanks=False) + " (video)",url,12,iconimage,songname,artist,'na','na',vurl)
  247.     addDir('>> Next Page','http://www.jango.com/my_song_history',9952,art + 'icon_next_page.jpg',str(nextpage),'')
  248.  
  249. class play_timer(Thread):
  250.     def __init__(self,url,name,token,iconimage,streamurl,stid):
  251.         time.sleep(3)
  252.         self.url=url
  253.         self.name=name
  254.         self.token=token
  255.         self.iconimage=iconimage
  256.         self.streamurl=streamurl
  257.         self.stid=stid
  258.         Thread.__init__(self)
  259.  
  260.     def run(self):
  261.         start_time = time.time()
  262.         url=self.url
  263.         name=self.name
  264.         token=self.token
  265.         iconimage=self.iconimage
  266.         streamurl=self.streamurl
  267.         stid=self.stid
  268.         #print "HAS NEXT " + str(xbmc.getCondVisibility('MusicPlayer.HasNext'))
  269.         secs=0
  270.         while xbmc.Player().isPlayingAudio() and xbmcgui.Window(10000).getProperty("station_id")==stid:#secs < (int(dur)-25) and xbmc.Player().isPlayingAudio() and streamurl==playerurl:
  271.             while xbmc.getCondVisibility('MusicPlayer.HasNext'):
  272.                 if xbmcgui.Window(10000).getProperty("station_id")==stid:
  273.                     secs += 1
  274.                     time.sleep(1)
  275.                 else:
  276.                     #print "STAION CHANGED " + stid
  277.                     break
  278.             time.sleep(3)
  279.             if xbmcgui.Window(10000).getProperty("station_id")==stid:
  280.                 #print "NOW ADD TRACK TO PLAYLIST: Playlist has next item is " + str(xbmc.getCondVisibility('MusicPlayer.HasNext'))
  281.                 play_song(url, name, token, iconimage,stid,False,False)
  282.  
  283.          
  284. def play_song(url, name, token, iconimage,stid, clear, skip):
  285.     userid=xbmcgui.Window(10000).getProperty("user_id")
  286.     if len(userid)>4:
  287.         uid='&uid=%s' % userid
  288.     else:
  289.         uid=''
  290.     curr_time=int(round(time.time() * 1000))
  291.     origurl=url
  292.     origtoken=token
  293.     pl = get_XBMCPlaylist(clear)
  294.     playlist=[]
  295.     contenttime=xbmcgui.Window(10000).getProperty("contenttime")
  296.     sid=xbmcgui.Window(10000).getProperty("sid")
  297.     headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-Requested-With': 'XMLHttpRequest'}
  298.     if clear:
  299.         f = open(ACTIVEPL, 'w')
  300.         f.close
  301.         url='http://www.jango.com/stations/%s/play?_=%s' % (stid,curr_time)
  302.     elif skip:
  303.         url='http://www.jango.com/streams/info?sid=%s%s&stid=%s&ver=11&skipped=1&cb=%s&_=%s' % (sid,uid,stid,curr_time,contenttime)
  304.     else:
  305.         url='http://www.jango.com/streams/info?sid=%s%s&stid=%s&ver=11&next=1&cb=%s&_=%s' % (sid,uid,stid,curr_time,contenttime)
  306.     net.set_cookies(cookie_jar)
  307.     link = net.http_GET(url,headers=headers).content.encode("utf-8").replace('\n','')
  308.     net.save_cookies(cookie_jar)
  309.     url='http:' + regex_from_to(link,'"url":"','"')
  310.     artist=regex_from_to(link,'artist":"','"')
  311.     artistid=regex_from_to(link,'artist_id":',',"')
  312.     artistlink=""
  313.     songname=regex_from_to(link,'song":"','"')
  314.     songid=regex_from_to(link,'"song_id":',',"')
  315.     genre=regex_from_to(link,'"genre":"','"')
  316.     similarartists=regex_from_to(link,'similar_stations":',']')
  317.     try:
  318.         videoid=regex_from_to(link,'video_id":"','"')
  319.     except:
  320.         videoid="na"
  321.     albumart='http:'+ regex_from_to(link,'album_art":"',',"').replace('_sm','_xl')
  322.     stationname=regex_from_to(link,'station":"','"')
  323.     title = "%s | %s" % (artist,songname)
  324.     PL_TEXT="%s<>%s<>%s<>%s<>%s<>%s<>%s<>%s<>%s<>%s" % (title,url,albumart,songname,artist,stationname,songid,videoid,genre,artistlink)
  325.     add_to_list(PL_TEXT,ACTIVEPL,False)
  326.     addDir("[COLOR lime]"+stationname+" (edit station...)[/COLOR]",'url',99000,iconimage,'na','na')
  327.     addDirAudio("Previous Song",origurl,16,iconimage,origtoken,stid,'na','na','na')
  328.     addDirAudio("Skip Song",origurl,11,iconimage,origtoken,stid,'na','na','na')
  329.     addDir("View Playlist",origurl,17,iconimage,origtoken,stid)
  330.     addDirAudio("[COLOR cyan]  Similar Stations[/COLOR]",'url',10000,iconimage,'na','na','na','na','na')
  331.     match=re.compile('"station_id":(.+?),"station_name":"(.+?)"').findall(similarartists)
  332.     for s_stationid,s_stationname in match:
  333.         s_url='http://www.jango.com/stations/%s/tunein' % s_stationid
  334.         addDir("  "+clean_file_name(s_stationname, use_blanks=False),s_url,10,iconimage,token,s_stationid) 
  335.     liz=xbmcgui.ListItem(songname, iconImage=iconimage, thumbnailImage=iconimage)
  336.     liz.setInfo('music', {'Title':songname, 'Artist':artist, 'Album':stationname })
  337.     liz.setProperty('mimetype', 'audio/mpeg')
  338.     liz.setProperty("IsPlayable","true")
  339.     liz.setThumbnailImage(iconimage)
  340.     if clear or ((xbmcgui.Window(10000).getProperty("station_id")=="" or xbmcgui.Window(10000).getProperty("station_id")==stid) and not clear):
  341.         playlist.append((url, liz))
  342.         for blob ,liz in playlist:
  343.             try:
  344.                 if blob:
  345.                     pl.add(blob,liz)
  346.             except:
  347.                 pass
  348.     if clear:
  349.         xbmc.Player().play(pl)
  350.         xbmcgui.Window(10000).clearProperty("station_id")
  351.         xbmcgui.Window(10000).setProperty("station_id", stid)
  352.         playThread = play_timer(origurl,name,origtoken,iconimage,url,stid)
  353.         playThread.start()
  354.     if skip:
  355.         xbmc.executebuiltin('XBMC.Playlist.PlayOffset(1)')
  356.  
  357. def previous_track():
  358.     xbmc.executebuiltin('XBMC.Playlist.PlayOffset(-1)')
  359.    
  360. def track_history():
  361.     if os.path.isfile(ACTIVEPL):
  362.         s = read_from_file(ACTIVEPL)
  363.         search_list = s.split('\n')
  364.         for list in search_list:
  365.             if list != '':
  366.                 list1 = list.split('<>')
  367.                 title = "  " + list1[0]
  368.                 url = list1[1]
  369.                 albumart = list1[2]
  370.                 songname = list1[3]
  371.                 artist = list1[4]
  372.                 stationname = list1[5]
  373.                 songid = list1[6]
  374.                 videoid = list1[7]
  375.                 genre = list1[8]
  376.                 artistlink = list1[9]
  377.                 addDirAudio(title,url,18,albumart,genre,artist,stationname,songid,artistlink)
  378.                
  379. def track_options(name,url,iconimage,genre,artist,album,songid,artistlink):
  380.     dialog = xbmcgui.Dialog()
  381.     option_list = ["[COLOR lime]Thumbs Up[/COLOR]","[COLOR orange]Thumbs Down[/COLOR]","View stations with " + artist,"View biography for " + artist]
  382.     option_id = dialog.select("Song/Artist Options", option_list)
  383.     if(option_id < 0):
  384.         return (None, None)
  385.         dialog.close()
  386.     if(option_id == 0):
  387.         thumbs_up(name, url,iconimage,songid)
  388.     elif(option_id == 1):
  389.         thumbs_down(name, url,iconimage,songid)
  390.     elif(option_id == 2):
  391.         token=xbmcgui.Window(10000).getProperty("token")
  392.         xbmc.executebuiltin('Container.Update(%s?name=%s&url=%s&mode=3&type=%s)'%(sys.argv[0], urllib.quote(artist), urllib.quote_plus(artistlink), urllib.quote(token)))
  393.     elif(option_id == 3):
  394.         artist_bio(artist,iconimage,artistlink + '/_full_bio')
  395.        
  396. def artist_bio(artist,iconimage,url):
  397.     url=url.replace(' ','+')
  398.     net.set_cookies(cookie_jar)
  399.     link = net.http_GET(url).content.encode("utf-8")
  400.     net.save_cookies(cookie_jar)
  401.     biobody=regex_from_to(link,'<div class="artist-bio" style="margin:20px 0; clear:both">','<div class="wiki_link"')
  402.  
  403.     text=biobody.replace('</p><p>', '\n').replace('</p></p>', '').replace('<p><p>', '').replace('<br />', '\n')#.replace('<p>', '\n')
  404.     #biobody = re.sub(r'<.+?>', '', newsbody).replace('<>', '')
  405.     header = "[B][COLOR gold]" + artist + "[/B][/COLOR]"
  406.     TextBoxes(header,text)
  407.    
  408. def TextBoxes(heading,anounce):
  409.         class TextBox():
  410.             """Thanks to BSTRDMKR for this code:)"""
  411.                 # constants
  412.             WINDOW = 10147
  413.             CONTROL_LABEL = 1
  414.             CONTROL_TEXTBOX = 5
  415.  
  416.             def __init__( self, *args, **kwargs):
  417.                 # activate the text viewer window
  418.                 xbmc.executebuiltin( "ActivateWindow(%d)" % ( self.WINDOW, ) )
  419.                 # get window
  420.                 self.win = xbmcgui.Window( self.WINDOW )
  421.                 # give window time to initialize
  422.                 xbmc.sleep( 500 )
  423.                 self.setControls()
  424.  
  425.  
  426.             def setControls( self ):
  427.                 # set heading
  428.                 self.win.getControl( self.CONTROL_LABEL ).setLabel(heading)
  429.                 try:
  430.                         f = open(anounce)
  431.                         text = f.read()
  432.                 except:
  433.                         text=anounce
  434.                 self.win.getControl( self.CONTROL_TEXTBOX ).setText(text)
  435.                 return
  436.         TextBox()
  437.        
  438. def station_edit(name,url,iconimage):
  439.     curr_time=int(round(time.time() * 1000))
  440.     url='http://www.jango.com/quickmixes/suggestions?_=%s' % curr_time
  441.     token=xbmcgui.Window(10000).getProperty("token")
  442.     headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': '*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript', 'X-CSRF-Token': token, 'X-Requested-With': 'XMLHttpRequest'}
  443.     net.set_cookies(cookie_jar)
  444.     link = net.http_GET(url,headers=headers).content.encode("utf-8").replace('\n','').replace('\\','')
  445.     net.save_cookies(cookie_jar)
  446.     addDir("[COLOR lime]Search Any Artist[/COLOR]",'url',99002,iconimage,'na','na')
  447.     all_artists=regex_get_all(link,'<li>','/li>')
  448.     for a in all_artists:
  449.         title=regex_from_to(a,'button>','<')
  450.         url=urllib.unquote('http://www.jango.com/' +(regex_from_to(a,'<a href="/','"')))
  451.         addDirAudio(title,url,99001,iconimage,'na','na','na','na','na')
  452.        
  453. def station_edit_search(name, url,iconimage):
  454.     keyboard = xbmc.Keyboard('', name, False)
  455.     keyboard.doModal()
  456.     if keyboard.isConfirmed():
  457.         query = keyboard.getText()
  458.         if len(query) > 0:
  459.             curr_time=int(round(time.time() * 1000))
  460.             token=xbmcgui.Window(10000).getProperty("token")
  461.             headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-CSRF-Token': token, 'X-Requested-With': 'XMLHttpRequest'}
  462.             url = 'http://www.jango.com/artists/jsearch?term=%s&cb=add&source=quickmix&_=%s' % (urllib.quote_plus(query),str(curr_time))
  463.             net.set_cookies(cookie_jar)
  464.             link = net.http_GET(url,headers=headers).content.replace('\n','')
  465.             net.save_cookies(cookie_jar)
  466.             match=re.compile('{"label":"(.+?)","value":"(.+?)","id":(.+?),"url":"(.+?)","station_id":(.+?)}').findall(link)
  467.             for title,value,id,url,stid in match:
  468.                 addDirAudio(title,url,99003,iconimage,id,stid,'na','na','na')
  469.        
  470. def station_edit_add(name,url,iconimage):
  471.     cj = cookielib.LWPCookieJar(cookie_jar)
  472.     cj.load()
  473.     userid=xbmcgui.Window(10000).getProperty("user_id")
  474.     token=xbmcgui.Window(10000).getProperty("token")
  475.     referer='http://www.jango.com/profiles/%s' % userid
  476.     payload=None
  477.     #net.set_cookies(cookie_jar)
  478.     headers = {'Host': 'www.jango.com','Content-Length':'0','Referer': referer,'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': '*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript', 'X-CSRF-Token': token, 'X-Requested-With': 'XMLHttpRequest'}
  479.     try:
  480.         link=requests.post(url,headers=headers,data=payload,cookies=cj).content.replace('\\','').replace('\n','')
  481.         cj.save()
  482.         lsn=regex_from_to(link,'limited_station_name": "','"')
  483.         if 'We have added' in link:
  484.             notification(name, "Added to your station", '4000',iconimage)
  485.     except:
  486.         pass
  487.  
  488.    
  489. def station_edit_add2(name,url,iconimage,id,stid):
  490.     cj = cookielib.LWPCookieJar(cookie_jar)
  491.     cj.load()
  492.     userid=xbmcgui.Window(10000).getProperty("user_id")
  493.     token=xbmcgui.Window(10000).getProperty("token")
  494.     referer='http://www.jango.com/profiles/%s' % userid
  495.     payload={'artist_id': id,'inline':'true'}
  496.     headers = {'Host': 'www.jango.com','Content-Length':'0','Referer': referer,'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': '*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript', 'X-CSRF-Token': token, 'X-Requested-With': 'XMLHttpRequest'}
  497.     try:
  498.         link=requests.post('http://www.jango.com/quickmixes',headers=headers,data=payload,cookies=cj).content.replace('\\','').replace('\n','')
  499.         cj.save()
  500.         lsn=regex_from_to(link,'limited_station_name": "','"')
  501.         if 'We have added' in link:
  502.             notification(name, "Added to your station", '4000',iconimage)
  503.     except:
  504.         pass
  505.    
  506. def play_track(name,url,iconimage,artist,song,clear,skip):
  507.     token=xbmcgui.Window(10000).getProperty("token")
  508.     userid=xbmcgui.Window(10000).getProperty("user_id")
  509.     if len(userid)>4:
  510.         uid='&uid=%s' % userid
  511.     else:
  512.         uid=''
  513.     curr_time=int(round(time.time() * 1000))
  514.     origurl=url
  515.     origtoken=token
  516.     pl = get_XBMCPlaylist(clear)
  517.     playlist=[]
  518.     contenttime=xbmcgui.Window(10000).getProperty("contenttime")
  519.     sid=xbmcgui.Window(10000).getProperty("sid")
  520.     headers = {'Host': 'www.jango.com','Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': 'application/json, text/javascript, */*; q=0.01', 'X-Requested-With': 'XMLHttpRequest', 'X-CSRF-Token': token}
  521.     url='http://www.jango.com/stations/airplay_song_tunein/play?song_id=%s&_=%s' % (origurl,curr_time)
  522.     net.set_cookies(cookie_jar)
  523.     link = net.http_GET(url,headers=headers).content.encode("utf-8").replace('\n','')
  524.     net.save_cookies(cookie_jar)
  525.     url=regex_from_to(link,'"url":"','"')
  526.     artist=regex_from_to(link,'artist":"','"')
  527.     artistid=regex_from_to(link,'artist_id":',',"')
  528.     songname=regex_from_to(link,'song":"','"')
  529.     songid=regex_from_to(link,'"song_id":',',"')
  530.     try:
  531.         videoid=regex_from_to(link,'video_id":"','"')
  532.     except:
  533.         videoid="na"
  534.     albumart=regex_from_to(link,'album_art":"',',"').replace('_sm','_xl')
  535.     stationname=regex_from_to(link,'station":"','"')
  536.     title = "%s | %s" % (artist,songname)
  537.     addDirAudio(title,url,10,albumart,songname,artist,stationname,songid,videoid)
  538.     liz=xbmcgui.ListItem(songname, iconImage=albumart, thumbnailImage=albumart)
  539.     liz.setInfo('music', {'Title':songname, 'Artist':artist, 'Album':stationname })
  540.     liz.setProperty('mimetype', 'audio/mpeg')
  541.     liz.setProperty("IsPlayable","true")
  542.     liz.setThumbnailImage(albumart)
  543.     if clear or ((xbmcgui.Window(10000).getProperty("station_id")=="" or xbmcgui.Window(10000).getProperty("station_id")==stid) and not clear):
  544.         playlist.append((url, liz))
  545.         for blob ,liz in playlist:
  546.             try:
  547.                 if blob:
  548.                     pl.add(blob,liz)
  549.             except:
  550.                 pass
  551.     if clear:
  552.         xbmc.Player().play(pl)
  553.    
  554. def play_video(name,url,iconimage,artist,song,mix,clear):
  555.     listitem = xbmcgui.ListItem(name, iconImage=iconimage, thumbnailImage=iconimage, path=url)
  556.     xbmcPlayer = xbmc.Player(xbmc.PLAYER_CORE_AUTO)
  557.     handle = str(sys.argv[1])    
  558.     if handle != "-1":
  559.         listitem.setProperty("IsPlayable", "true")
  560.         xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
  561.     else:
  562.         xbmcPlayer.play(url, listitem)
  563.        
  564. def thumbs_up(name, url,iconimage,songid):
  565.     token=xbmcgui.Window(10000).getProperty("token")
  566.     if dialog.yesno("Confirm", 'Click Confirm and this song, and others similar to it,', 'will play more often in this station.',"We'll also add the song to your favourites",'Cancel','Confirm'):
  567.         url="http://www.jango.com/song_ratings/add_favorite?song_id=%s" % songid
  568.         headers = {'Host': 'www.jango.com', 'Referer': 'http://www.jango.com/', 'X-Requested-With': 'XMLHttpRequest', 'Accept': '*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript'}
  569.         payload = {'authenticity_token': token, 'commit': 'Confirm', 'utf8': '%E2%9C%93'}
  570.         net.set_cookies(cookie_jar)
  571.         link = net.http_POST(url,headers=headers,form_data=payload).content.encode("utf-8").replace('\n','')
  572.         net.save_cookies(cookie_jar)
  573.  
  574.  
  575. def thumbs_down(name, url,iconimage,songid):
  576.     token=xbmcgui.Window(10000).getProperty("token")
  577.     url='http://www.jango.com/song_ratings/add_ban?song_id=%s' % songid
  578.     headers = {'Host': 'www.jango.com', 'Referer': 'http://www.jango.com/', 'X-Requested-With': 'XMLHttpRequest', 'Accept': '*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript'}
  579.     payload = {'authenticity_token': token, 'commit': 'Confirm', 'utf8': '%E2%9C%93', 'song_id': songid}
  580.     net.set_cookies(cookie_jar)
  581.     link = net.http_POST(url,headers=headers,form_data=payload).content.encode("utf-8").replace('\n','')
  582.     net.save_cookies(cookie_jar)
  583.    
  584. def remove_from_fav(name, url,iconimage,songid):
  585.     cj = cookielib.LWPCookieJar(cookie_jar)
  586.     cj.load()
  587.     token=xbmcgui.Window(10000).getProperty("token")
  588.     url='http://www.jango.com/song_ratings/delete_favorite?song_id=%s' % songid
  589.     headers = {'Host': 'www.jango.com','Content-Length':'0','Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': '*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript', 'X-CSRF-Token': token, 'X-Requested-With': 'XMLHttpRequest'}
  590.     payload = {}
  591.     link=requests.post(url,headers=headers,data=payload,cookies=cj).content
  592.     cj.save()
  593.     xbmc.executebuiltin("Container.Refresh")
  594.  
  595. def remove_from_ban(name, url,iconimage,songid):
  596.     cj = cookielib.LWPCookieJar(cookie_jar)
  597.     cj.load()
  598.     token=xbmcgui.Window(10000).getProperty("token")
  599.     url='http://www.jango.com/song_ratings/delete_ban?song_id=%s' % songid
  600.     headers = {'Host': 'www.jango.com','Content-Length':'0','Referer': 'http://www.jango.com/song_ratings/favorites','User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:41.0) Gecko/20100101 Firefox/41.0', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'en-US,en;q=0.5', 'Accept': '*/*;q=0.5, text/javascript, application/javascript, application/ecmascript, application/x-ecmascript', 'X-CSRF-Token': token, 'X-Requested-With': 'XMLHttpRequest'}
  601.     payload = {}
  602.     link = requests.post(url,headers=headers,data=payload,cookies=cj).content
  603.     cj.save()
  604.     xbmc.executebuiltin("Container.Refresh")
  605.  
  606.  
  607.  
  608. def find_list(query, search_file):
  609.     try:
  610.         content = read_from_file(search_file)
  611.         lines = content.split('\n')
  612.         index = lines.index(query)
  613.         return index
  614.     except:
  615.         return -1
  616.        
  617. def add_to_list(list, file, refresh):
  618.     if find_list(list, file) >= 0:
  619.         return
  620.  
  621.     if os.path.isfile(file):
  622.         content = read_from_file(file)
  623.     else:
  624.         content = ""
  625.  
  626.     lines = content.split('\n')
  627.     s = '%s\n' % list
  628.     for line in lines:
  629.         if len(line) > 0:
  630.             s = s + line + '\n'
  631.     write_to_file(file, s)
  632.     if refresh == True:
  633.         xbmc.executebuiltin("Container.Refresh")
  634.    
  635. def remove_from_list(list, file):
  636.     list = list.replace('<>Ungrouped', '').replace('All Songs', '')
  637.     index = find_list(list, file)
  638.     if index >= 0:
  639.         content = read_from_file(file)
  640.         lines = content.split('\n')
  641.         lines.pop(index)
  642.         s = ''
  643.         for line in lines:
  644.             if len(line) > 0:
  645.                 s = s + line + '\n'
  646.         write_to_file(file, s)
  647.         if not 'song' in file and not 'album' in file:
  648.             xbmc.executebuiltin("Container.Refresh")
  649.        
  650. def write_to_file(path, content, append=False, silent=False):
  651.     try:
  652.         if append:
  653.             f = open(path, 'a')
  654.         else:
  655.             f = open(path, 'w')
  656.         f.write(content)
  657.         f.close()
  658.         return True
  659.     except:
  660.         if not silent:
  661.             print("Could not write to " + path)
  662.         return False
  663.  
  664. def read_from_file(path, silent=False):
  665.     try:
  666.         f = open(path, 'r')
  667.         r = f.read()
  668.         f.close()
  669.         return str(r)
  670.     except:
  671.         if not silent:
  672.             print("Could not read from " + path)
  673.         return None
  674.        
  675. def notification(title, message, ms, nart):
  676.     xbmc.executebuiltin("XBMC.notification(" + title + "," + message + "," + ms + "," + nart + ")")
  677.        
  678. def get_params():
  679.         param=[]
  680.         paramstring=sys.argv[2]
  681.         if len(paramstring)>=2:
  682.                 params=sys.argv[2]
  683.                 cleanedparams=params.replace('?','')
  684.                 if (params[len(params)-1]=='/'):
  685.                         params=params[0:len(params)-2]
  686.                 pairsofparams=cleanedparams.split('&')
  687.                 param={}
  688.                 for i in range(len(pairsofparams)):
  689.                         splitparams={}
  690.                         splitparams=pairsofparams[i].split('=')
  691.                         if (len(splitparams))==2:
  692.                                 param[splitparams[0]]=splitparams[1]
  693.                                
  694.         return param
  695.  
  696.  
  697. def get_XBMCPlaylist(clear):
  698.     pl=xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
  699.     if clear:
  700.         pl.clear()
  701.     return pl
  702.    
  703. def clear_playlist():
  704.     pl=xbmc.PlayList(xbmc.PLAYLIST_MUSIC)
  705.     pl.clear()
  706.     notification('Playlist', 'Cleared', '2000', iconart)
  707.  
  708.    
  709. def create_directory(dir_path, dir_name=None):
  710.     if dir_name:
  711.         dir_path = os.path.join(dir_path, dir_name)
  712.     dir_path = dir_path.strip()
  713.     if not os.path.exists(dir_path):
  714.         os.makedirs(dir_path)
  715.     return dir_path
  716.  
  717. def create_file(dir_path, file_name=None):
  718.     if file_name:
  719.         file_path = os.path.join(dir_path, file_name)
  720.     file_path = file_path.strip()
  721.     if not os.path.exists(file_path):
  722.         f = open(file_path, 'w')
  723.         f.write('')
  724.         f.close()
  725.     return file_path
  726.    
  727. def regex_from_to(text, from_string, to_string, excluding=True):
  728.     if excluding:
  729.         r = re.search("(?i)" + from_string + "([\S\s]+?)" + to_string, text).group(1)
  730.     else:
  731.         r = re.search("(?i)(" + from_string + "[\S\s]+?" + to_string + ")", text).group(1)
  732.     return r
  733.  
  734. def regex_get_all(text, start_with, end_with):
  735.     r = re.findall("(?i)(" + start_with + "[\S\s]+?" + end_with + ")", text)
  736.     return r
  737.    
  738. def setView(content, viewType):
  739.     if content:
  740.         xbmcplugin.setContent(int(sys.argv[1]), content)
  741.  
  742. def addLink(name,url,iconimage):
  743.         ok=True
  744.         liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png", thumbnailImage=iconimage)
  745.         liz.setInfo( type="Audio", infoLabels={ "Title": name } )
  746.         liz.setProperty('fanart_image', audio_fanart)
  747.         ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
  748.         return ok
  749.  
  750.  
  751. def addDir(name,url,mode,iconimage,type,id):
  752.         u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&list="+str(list)+"&type="+urllib.quote_plus(type)+"&id="+urllib.quote_plus(id)
  753.         ok=True
  754.         contextMenuItems = []
  755.         liz=xbmcgui.ListItem(name, iconImage="DefaultAudio.png", thumbnailImage=iconimage)
  756.         liz.addContextMenuItems(contextMenuItems, replaceItems=False)
  757.         liz.setInfo( type="Audio", infoLabels={ "Title": name } )
  758.         liz.setProperty('fanart_image', fanart)
  759.         ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
  760.         return ok
  761.        
  762. def addDirAudio(name,url,mode,iconimage,songname,artist,album,dur,type):
  763.         suffix = ""
  764.         contextMenuItems = []
  765.         u=sys.argv[0]+"?url="+urllib.quote_plus(url)+"&mode="+str(mode)+"&name="+urllib.quote_plus(name)+"&iconimage="+urllib.quote_plus(iconimage)+"&songname="+urllib.quote_plus(songname)+"&artist="+urllib.quote_plus(artist)+"&album="+urllib.quote_plus(album)+"&dur="+str(dur)+"&type="+str(type)
  766.         ok=True
  767.         liz=xbmcgui.ListItem(name + suffix, iconImage="DefaultAudio.png", thumbnailImage=iconimage)
  768.         if dur=="fav":
  769.             contextMenuItems.append(("[COLOR orange]Remove from Favourite Tracks[/COLOR]",'XBMC.RunPlugin(%s?name=%s&url=%s&mode=57&iconimage=%s&album=%s)'%(sys.argv[0], urllib.quote(name), urllib.quote(url),urllib.quote(iconimage),urllib.quote(album))))
  770.         if dur=="ban":
  771.             contextMenuItems.append(("[COLOR orange]Remove from Banned Tracks[/COLOR]",'XBMC.RunPlugin(%s?name=%s&url=%s&mode=58&iconimage=%s&album=%s)'%(sys.argv[0], urllib.quote(name), urllib.quote(url),urllib.quote(iconimage),urllib.quote(album))))
  772.         liz.addContextMenuItems(contextMenuItems, replaceItems=False)
  773.         liz.setInfo( type="Audio", infoLabels={ "Title": name } )
  774.         ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz)
  775.         return ok
  776.        
  777.              
  778. params=get_params()
  779. url=None
  780. name=None
  781. mode=None
  782. type=None
  783. id=None
  784.  
  785. try:
  786.         url=urllib.unquote_plus(params["url"])
  787. except:
  788.         pass
  789. try:
  790.         name=urllib.unquote_plus(params["name"])
  791. except:
  792.         pass
  793. try:
  794.         mode=int(params["mode"])
  795. except:
  796.         pass
  797. try:
  798.         iconimage=urllib.unquote_plus(params["iconimage"])
  799. except:
  800.         pass
  801. try:
  802.         songname=urllib.unquote_plus(params["songname"])
  803. except:
  804.         pass
  805. try:
  806.         artist=urllib.unquote_plus(params["artist"])
  807. except:
  808.         pass
  809. try:
  810.         album=urllib.unquote_plus(params["album"])
  811. except:
  812.         pass
  813. try:
  814.         list=str(params["list"])
  815. except:
  816.         pass
  817. try:
  818.         dur=str(params["dur"])
  819. except:
  820.         pass
  821. try:
  822.         type=urllib.unquote_plus(params["type"])
  823. except:
  824.         pass
  825. try:
  826.         id=urllib.unquote_plus(params["id"])
  827. except:
  828.         pass
  829.  
  830. if mode==None or url==None or len(url)<1:
  831.     login('https://www.jango.com/splogin')
  832.     CATEGORIES()
  833.  
  834. elif mode == 2:
  835.     music_sections(name, url)
  836.    
  837. elif mode == 3:
  838.     sub_sections(name, url, type)
  839.    
  840. elif mode == 10:
  841.         play_song(url,name,type,iconimage,id,True,False)
  842.        
  843. elif mode == 11:
  844.         play_song(url,name,songname,iconimage,artist,False,True)
  845.        
  846. elif mode == 14:
  847.         play_song(url,name,type,iconimage,id,False,False)
  848.  
  849. elif mode == 12:
  850.     play_video(name,url,iconimage,artist,songname,False,True)  
  851.  
  852. elif mode == 13:
  853.     play_track(name,url,iconimage,artist,songname,True,False)
  854.  
  855. elif mode == 16:
  856.     previous_track()
  857.  
  858. elif mode == 17:
  859.     track_history()
  860.    
  861. elif mode == 18:
  862.     track_options(name,url,iconimage,songname,artist,album,dur,type)
  863.  
  864. elif mode == 24:
  865.     search(name, url)
  866.  
  867. elif mode == 26:
  868.     search_songs(name)
  869.    
  870. elif mode == 27:
  871.     search_artists(name)
  872.  
  873. elif mode == 55:
  874.     thumbs_up(name, url,iconimage,dur)
  875.    
  876. elif mode == 56:
  877.     thumbs_down(name, url,iconimage,dur)
  878.    
  879. elif mode == 57:
  880.     remove_from_fav(name, url,iconimage,album)
  881.    
  882. elif mode == 58:
  883.     remove_from_ban(name, url,iconimage,album)
  884.    
  885. elif mode == 9999:
  886.     login(url)
  887.    
  888. elif mode == 9998:
  889.     login2()
  890.  
  891. elif mode == 9950:
  892.     favourite_tracks(name,url,type)
  893.    
  894. elif mode == 9951:
  895.     station_history(type)
  896.    
  897. elif mode == 9952:
  898.     song_history(url,type)
  899.    
  900. elif mode == 99000:
  901.     station_edit(name,url,iconimage)
  902.    
  903. elif mode == 99001:
  904.     station_edit_add(name,url,iconimage)
  905.    
  906. elif mode == 99002:
  907.     station_edit_search(name, url,iconimage)
  908.    
  909. elif mode == 99003:
  910.     station_edit_add2(name,url,iconimage,songname,artist)
  911.    
  912. xbmcplugin.endOfDirectory(int(sys.argv[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement