The branch, eden has been updated
via cbe8412038c9d59bdc968ac1a8cbffa1ae0d5a7d (commit)
from 52b99b3efb655a9ef1000f4a7262c379f34501ea (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=cbe8412038c9d59bdc968ac1a8cbffa1ae0d5a7d
commit cbe8412038c9d59bdc968ac1a8cbffa1ae0d5a7d
Author: unknown <[email protected]>
Date: Wed Aug 8 08:34:41 2012 +0200
[plugin.audio.mp3search] -v0.2.1
diff --git a/plugin.audio.mp3search/addon.xml b/plugin.audio.mp3search/addon.xml
index 144b3af..b525c12 100644
--- a/plugin.audio.mp3search/addon.xml
+++ b/plugin.audio.mp3search/addon.xml
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.audio.mp3search"
name="MP3 Search"
- version="0.1.0"
+ version="0.2.1"
provider-name="[email protected]">
<requires>
<import addon="xbmc.python" version="2.0"/>
+ <import addon="script.module.simple.downloader.beta" version="0.9.1"/>
</requires>
<extension point="xbmc.python.pluginsource"
provides="audio"
@@ -13,8 +14,8 @@
</extension>
<extension point="xbmc.addon.metadata">
<language></language>
- <summary lang="en">Search and play mp3's </summary>
- <description lang="en">Search and play mp3's</description>
+ <summary lang="en">Search,play and download mp3's </summary>
+ <description lang="en">With this addon you can search for mp3's, listen
and download them.</description>
<disclaimer></disclaimer>
<platform>all</platform>
</extension>
diff --git a/plugin.audio.mp3search/changelog.txt
b/plugin.audio.mp3search/changelog.txt
index f075b02..b2d1a29 100644
--- a/plugin.audio.mp3search/changelog.txt
+++ b/plugin.audio.mp3search/changelog.txt
@@ -1,2 +1,16 @@
+[B]0.2.1:[/B]
+Updated due to site changes (grrrr...)
+
+- different access to site
+- searched (and found) songs are now 'playable'
+- mined song name, artist, album and some other atributes
+- items can be downloaded (via context menu) - still experimental
+ Thanx to simple.downloader plugin !
+ Dont forget to setup download path in plugin settings
+
+
[B]0.1.0:[/B]
First version - please report bugs to [email protected]
+
+
+
diff --git a/plugin.audio.mp3search/default.py
b/plugin.audio.mp3search/default.py
index 928cb8c..b57fb90 100644
--- a/plugin.audio.mp3search/default.py
+++ b/plugin.audio.mp3search/default.py
@@ -2,11 +2,15 @@
# -*- coding: utf-8 -*-
import urllib,urllib2,re,xbmc,xbmcgui,xbmcplugin,sys,os,xbmcaddon,string
+import SimpleDownloader as downloader
+downloader = downloader.SimpleDownloader()
+
+
# plugin constants
__plugin__ = "mp3search"
__author__ = "[email protected]"
__url__ = ""
-__version__ = "0.1"
+__version__ = "0.2.1"
@@ -18,26 +22,54 @@ __icons__=os.path.join(__home__,'resources')
icon = xbmc.translatePath( os.path.join( __home__, 'icon.png' ) )
searchicon = xbmc.translatePath( os.path.join( __home__,'resources',
'search.png' ) )
playicon = xbmc.translatePath( os.path.join( __home__,'resources', 'play.png'
) )
-
+downloadpath= __settings__.getSetting('download_path')#__profile__
+phomepath=xbmc.translatePath( os.path.join( __home__, 'default.py' ) )
+debug=False
def replaceUrl(url):
a=string.replace(url,"%3A",":")
a=string.replace(a,"%2F","/")
return a
+def replaceUrlSpecial(url):
+ a=string.replace(url,"%3A",":")
+ a=string.replace(a,"%2F","/")
+ a=string.replace(a,"+","%20")
+ a=string.replace(a,"%2520","%20")
+ return a
+
+def getPageParam(page,param):
+ h=re.compile(param+'.+\s+<.+').findall(page)
+ if (len(h))>0:
+ g=re.compile('>([^<>\n\r]+)<').findall(h[0])
+ if (len(g))>0:
+ return g[0]
+ else:
+ return 'N/A'
+ else:
+ return 'N/F'
-def addLink(name, mode, url, desc, duration, iconimage,icolor=None):
-
u=sys.argv[0]+"?url="+urllib.quote_plus(replaceUrl(url))+"&mode="+urllib.quote_plus(str(mode))+"&cmd="+urllib.quote_plus(replaceUrl(url))+"&name="+urllib.quote_plus(name)+"&desc="+urllib.quote_plus(desc)+"&iconimage="+urllib.quote_plus(replaceUrl(iconimage))
+
+def downloadAudio(urlx,title,targetpath):
+ paramsd = { "url": replaceUrlSpecial(urlx), "download_path":
targetpath, "Title": title }
+ downloader.download(title+'.mp3', paramsd)
+
+
+
+def addLink(name, artist, album, mode, urlx, desc, descfile, duration,
iconimage,icolor=None):
+
u=sys.argv[0]+"?url="+urllib.quote_plus(replaceUrl(urlx))+"&mode="+urllib.quote_plus(str(mode))+"&cmd="+urllib.quote_plus(replaceUrl(urlx))+"&name="+urllib.quote_plus(name)+"&desc="+urllib.quote_plus(desc)+"&iconimage="+urllib.quote_plus(replaceUrl(iconimage))
ok=True
if icolor != None:
liz=xbmcgui.ListItem(label="[COLOR FF" + icolor + "]" + name +
"[/COLOR]", iconImage=iconimage, thumbnailImage=iconimage)
else:
liz=xbmcgui.ListItem(name, iconImage=iconimage,
thumbnailImage=iconimage)
- liz.setInfo( type="Music", infoLabels={ "Title": name, "Plot": desc,
"Duration": duration } )
- liz.setProperty("IsPlayable","false")
+ liz.setInfo( type="Music", infoLabels={ "Title": name, 'artist':
artist, 'album': album, 'Comment': desc, 'Duration': duration, 'File': descfile
} )
+ contextMenu =
[(__language__(30009),'XBMC.RunScript('+phomepath+',0,"?mode=down&url='+urllib.quote_plus(urlx)+'&desc=&name='+name+'&cmd=down")')]
+ liz.addContextMenuItems(contextMenu)
-
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
+ liz.setProperty("IsPlayable","true")
+
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=urlx,listitem=liz,isFolder=False)
@@ -51,29 +83,16 @@ def addDir(name, url, mode, cmd, desc,
iconimage,icolor=None):
liz.setInfo( type="Audio", infoLabels={ "Title": name, "Plot": desc } )
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
+
# Get a search query from keyboard
-def readKbd():
- kb = xbmc.Keyboard("",__language__(30006), False)
+def readKbd(default):
+ kb = xbmc.Keyboard(default,__language__(30006), False)
kb.doModal()
if (kb.isConfirmed() and len(kb.getText()) > 2):
return kb.getText()
-# Play a link
-def playLink(listen_url,lstItem=None,isave=True):
-
- if isave:
- aplayed=getDatFile("played.dat")
- if aplayed == None:
- aplayed=[listen_url]
- else:
- aplayed.append(listen_url)
-
- saveDatFile("played.dat",aplayed)
- xbmc.Player().play(replaceUrl(listen_url),lstItem)
-
-
#read dat file
def getDatFile(dfilepath):
if os.path.isfile(__profile__ + dfilepath):
@@ -116,9 +135,11 @@ def getParams():
param[splitparams[0]]=splitparams[1]
return param
+
+
+
#fill up searched
def fillSearched():
- #1.nacist
ax=getDatFile("searched.dat")
try:
@@ -131,21 +152,6 @@ def fillSearched():
xbmcplugin.endOfDirectory(int(sys.argv[1]))
-#fill up searched
-def fillPlayed():
- #1.load file
- ax=getDatFile("played.dat")
- try:
-
- if len(ax)>0:
- for sidx in range(len(ax)):
-
m=re.compile("downloadmp3-(.+?)\.xhtml").findall(ax[sidx])
- addLink(m[0],"played-item", ax[sidx],
'','unknown', playicon,"8080FF")
-
- except:
- pass
- xbmcplugin.endOfDirectory(int(sys.argv[1]))
-
#do search
def doSearch(fquery,fpage,isave=True):
@@ -157,26 +163,14 @@ def doSearch(fquery,fpage,isave=True):
req.add_header('Cache-Control',' no-cache')
req.add_header('Connection',' close')
- try:
- response = urllib2.urlopen(req)
- link=response.read()
-
-
- response.close()
-
- match=re.compile('<a
href="http://togrool.com/download(.+?)\?').findall(link)
- match2=re.compile('<div class="img"><img src="(.+?)"').findall(link)
- match3=re.compile('<div
class="item-title">(.+?)<.+?>(.+?)<').findall(link)
-
- kusurl='http://togrool.com/downloadmp3'
+ try:
+ response = urllib2.urlopen(req)
+ link=response.read()
+ response.close()
+ match=re.compile('<a
href="http://togrool.com/download(.+?)\?').findall(link)
- if len(match)==0:
-
#xbmc.executebuiltin('XBMC.Notification("'+__language__(30003)+'","'+__language__(30004)+'",5000,"'+icon+'")')
- pass
- else:
- if isave:
-
+ if isave:
asearched=getDatFile("searched.dat")
if asearched == None:
asearched=[fquery]
@@ -184,75 +178,94 @@ def doSearch(fquery,fpage,isave=True):
asearched.append(fquery)
saveDatFile("searched.dat",asearched)
-
-
- for idx in range(0,len(match)):
- addLink(match3[idx][0]+match3[idx][1],"play",
kusurl+match[idx], '','unknown', match2[idx])
-
+ for i in range(len(match)):
+
+ req =
urllib2.Request('http://togrool.com/download'+match[i])
+ req.add_header('User-Agent', ' Mozilla/5.0 (Windows NT
5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1')
+ req.add_header('Cache-Control',' no-cache')
+ req.add_header('Connection',' keep-alive')
+
+ try:
+ response = urllib2.urlopen(req)
+ link=response.read()
+ response.close()
+ match1=re.compile('<param name="FlashVars"
value="mp3=(.+?\.mp3)').findall(link) #target mp3
+ match2=re.compile('<img
src="(.+?)"').findall(link) #target icon
+ if (len(match1))>0:
+
+ if (len(match2))>0:
+ icn=match2[0]
+ else:
+ icn=playicon
+
+ informations = '[COLOR
FF80AA20]Downloads:' + getPageParam(link,'Downloads:') + '[/COLOR] [COLOR
FF00CCCC]Rating:' + getPageParam(link,'Rating:') + '[/COLOR] [COLOR
FFAA4020]Size:' + getPageParam(link,'Size:') + '[/COLOR] [COLOR
FFCC00CC]Duration:' + getPageParam(link,'Duration:')+ '[/COLOR] [COLOR
FF0080CC]Lyrics:' + getPageParam(link,'Lyrics:')+ '[/COLOR] [COLOR
FF20EE20]Bitrate:' + getPageParam(link,'Bitrate:') + '[/COLOR] '
+ addLink(getPageParam(link,'Band
name:')+' - '+getPageParam(link,'Song name:'),getPageParam(link,'Band
name:'),getPageParam(link,'Album name:'),"play", replaceUrlSpecial(match1[0]),
informations,'','12:34',icn)
+
+ except urllib2.URLError, e:
+ pass
+
+
addDir('>> '+__language__(30005)+'
>>','','searchnext',fquery,str(fpage+1),'DefaultFolder.png',"FF80FF")
-
- xbmcplugin.endOfDirectory(int(sys.argv[1]))
+ xbmcplugin.endOfDirectory(int(sys.argv[1]))
+ #Container.SetViewMode(id)
+
+
+
except urllib2.URLError, e:
- dlg=xbmcgui.Dialog()
- tdlg=dlg.ok(__language__(30007),__language__(30007)+'
'+str(e.code),'')
+ pass
-# Main ----------------------------------------------------
+
+
+# Main
-------------------------------------------------------------------------------------------------
params=getParams()
+mode=''
+param1=''
+param2=''
+namet=''
+buurl=''
+
try:
+
+ buurl = params["url"]
mode = params["mode"]
param1 = params["cmd"]
param2 = params["desc"]
namet = params["name"]
-
-
-
+
except:
- mode = 0
+ mode = ''
# Menu stuff
if mode == "search":
- a_query = readKbd()
+ a_query = readKbd("")
if a_query != None:
doSearch(a_query,1,True)
#sort()
elif mode == "searched-item":
- a_query = namet
- doSearch(a_query,1,False)
+ a_query = readKbd(namet)
+ if a_query != None:
+ doSearch(a_query,1,False)
elif mode=='searched':
fillSearched()
-elif mode=='played':
- fillPlayed()
-
-elif mode=='played-item':
- playLink(param1,None,False)
-
-elif mode=='play':
- playLink(param1,None,True)
-
elif mode == "searchnext":
doSearch(param1,int(param2),False)
elif mode=='down':
- saveAudioFile(param1,__profile__)
-
+ downloadAudio(buurl,namet,downloadpath)
else:
addDir(__language__(30000)+' >','','search','','','DefaultFolder.png')
addDir(__language__(30001)+' >','','searched','','','DefaultFolder.png')
- addDir(__language__(30002)+' >','','played','','','DefaultFolder.png')
-
-
xbmcplugin.endOfDirectory(int(sys.argv[1]))
-
diff --git a/plugin.audio.mp3search/resources/language/English/strings.xml
b/plugin.audio.mp3search/resources/language/English/strings.xml
index 16ef777..9bbbca4 100644
--- a/plugin.audio.mp3search/resources/language/English/strings.xml
+++ b/plugin.audio.mp3search/resources/language/English/strings.xml
@@ -8,5 +8,7 @@
<string id="30005">Next Page</string>
<string id="30006">Enter keyword to search</string>
<string id="30007">Error</string>
+ <string id="30008">Download path</string>
+ <string id="30009">Download this MP3</string>
</strings>
-----------------------------------------------------------------------
Summary of changes:
plugin.audio.mp3search/addon.xml | 7 +-
plugin.audio.mp3search/changelog.txt | 14 ++
plugin.audio.mp3search/default.py | 191 +++++++++++---------
.../resources/language/English/strings.xml | 2 +
plugin.audio.mp3search/resources/settings.xml | 4 +
5 files changed, 126 insertions(+), 92 deletions(-)
create mode 100644 plugin.audio.mp3search/resources/settings.xml
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons