Ñò ˆ'$Jc@s=ddkZddkZddkZddkZddkZddkZddkZddkZeiƒddk l Z ddk Te eƒeidƒdefd„ƒYZd„Zd„Zd@d „Zd „Zd d „Zded„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z!d„Z"d„Z#d„Z$d„Z%hdd„Z&e'd jo¬eƒZ(e(i)ƒe*e(ƒei+ƒZ,e,i-d!ƒZ.e.oe.d"jo/e/d#d$ƒi0ƒZe1ee,i-d%ƒƒq.e.d&joXe,i2d'ƒoDe,i-d'ƒZ3ee3ƒZ4ee3ƒZ5e6e4e5e3d(eƒƒq×q.e.d)jo/ee,i-d&ƒƒZ7e8e(e7d(eƒƒq.e.d*jo/ee,i-d)ƒƒZ9e:e(e9d(eƒƒq.e.d+joe,i-d,ƒZ;e,i-d-ƒZ<e<d&jo&e!e;ƒZ=e>d.e=d(eƒƒq×e<d)jo&e"e;ƒZ=e>d/e=d(eƒƒq×e<d0jo&e#e;ƒZ=e>d1e=d(eƒƒq×e<d2jo&e$e;ƒZ=e>d3e=d(eƒƒq×e%e;ƒZ=e>d4e=d(eƒƒq.e.d5jo°e,i2d ƒo’e,i-d6ƒe(i?d6eƒd?eƒƒeDƒndS(AiÿÿÿÿN(tdbapi2(t*sutf-8tConfigcBs#eZd„Zd„Zd„ZRS(cCs h|_dS(N(tdict(tself((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyt__init__%scCs%tdƒiƒ}xµ|D]­}|iƒ}|djp|idƒoqn|idƒdidƒ\}}|iƒiddƒidƒ}t|ƒdjo|d}n||i|iƒs  cCsbtiƒ}|djotidƒntiƒtiƒ}|djotidƒndS(Ni(Rtforktsystexittsetsid(tpid((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyt become_daemonDs     i€cCsiddkl}|i|ƒ}|idjo|idƒ}n|i||iƒ|i|dƒdS(Niÿÿÿÿ(tImagetRGBtJPEG(tPILR4Rtmodetconvertt thumbnailt ANTIALIASR%(tpath_intpath_outtsizeR4timg((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytmake_thumbnailNs cCsîd}|ipt|d|ƒtS|idƒpt|d|ƒtS|idƒpt|d|ƒtS|idƒpt|d|ƒtS|id ƒpt|d |ƒtS|id ƒpt|d |ƒtStS( s4Check if the audio file have all the necessary tags.s(NOTAG) Invalid ID3 tags: ttitles (Title): talbums (Album): tartists (Artist): tdates (Year): t tracknumbers (Track): (ttagstlogtFalsethas_keytTrue(taudiotpathtmsg((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyt checktagsWs( tacCs.td|ƒ}|i|dƒ|iƒdS(Ns"../html/jukebox/config/jukebox.logs (RR#R$(RMtmethodtfile((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyRGosR ccsßti|ƒ}|p||fVnx|D]•}y"titii||ƒƒ}Wntij o q,nXti|iƒo>x;t tii||ƒ|ƒD]\}}||fVq¢Wq,q,W|o||fVndS(N( RRtlstatRLR"terrortstattS_ISDIRtst_modetwalktree(ttopt depthfirsttnamestnametsttnewtoptchildren((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyRWts" cCs2tƒ\}}|idƒiƒ}|iƒ|S(Ns"SELECT * FROM artist ORDER BY name(R)texecutetfetchallR$(R-R,tartists((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytget_all_artists„s cCs6tƒ\}}|id|ƒiƒ}|iƒ|S(NsÌSELECT artist.id artist_id, artist.name artist_name, album.* FROM album, artist WHERE artist.id=album.artist_id AND artist.id=%s ORDER BY album.year(R)R_R`R$(t artist_idR-R,talbums((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytget_all_albumsŠs  cCs6tƒ\}}|id|ƒiƒ}|iƒ|S(NseSELECT artist.id artist_id, artist.name artist_name, album.id album_id, album.name album_name, album.genre album_genre, album.year album_year, music.* FROM artist, album, music WHERE artist.id=album.artist_id AND album.id=music.album_id AND album.id=%s ORDER BY music.track(R)R_R`R$(talbum_idR-R,tmusics((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytget_all_musics’s  cCsqtƒ\}}|idƒiƒd}|idƒiƒd}|idƒiƒd}|iƒ|||fS(NsSELECT COUNT(*) FROM artistisSELECT COUNT(*) FROM albumsSELECT COUNT(*) FROM music(R)R_tfetchoneR$(R-R,RaRdRg((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyt gettotalinfo›s  cCs}tƒ\}}|id|ƒiƒd}|id|ƒiƒd}|id|ƒiƒd}|iƒ|||fS(Ns9SELECT COUNT(*) FROM artist WHERE upper(name) LIKE "%s%%"isgSELECT COUNT(*) FROM artist, album WHERE artist.id = album.artist_id and upper(artist.name) LIKE "%s%%"sŒSELECT COUNT(*) FROM artist, album, music WHERE artist.id = album.artist_id and album.id = music.album_id and upper(artist.name) LIKE "%s%%"(R)R_RiR$(tletterR-R,RaRdRg((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytgettotalinfostartswith£s  cCs6tƒ\}}|idƒiƒd}|iƒ|S(NsSELECT SUM(size) from musici(R)R_RiR$(R-R,t total_size((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyt gettotalsize«s cCs6tƒ\}}|idƒiƒd}|iƒ|S(NsSELECT SUM(length) from musici(R)R_RiR$(R-R,Rm((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyt gettotaltime±s cCs­d}|djoPx[tttddƒƒD]/}|djo|d7}n|d|7}q,Wn|d|7}|d 7}tƒ\}}|i|ƒiƒ}|iƒ|S( NsSELECT * FROM artist WHERE t0iAi[tAs and supper(name) not like "%s%%"supper(name) like "%s%%"s ORDER BY name(tmaptchrtrangeR)R_R`R$(RktsqltiR-R,Ra((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytgetartiststartswith·s    cCs2tƒ\}}|i|ƒiƒ}|iƒ|S(N(R)R_R`R$(RuR-R,tresult((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyt search_byÇs cCsd|}t|ƒS(NsMSELECT * FROM artist WHERE upper(name) like "%%%s%%" ORDER BY name(Ry(R[Ru((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytsearch_artists_by_nameÍs cCsd|}t|ƒS(Ns™SELECT artist.id, artist.name, album.id, album.name FROM artist, album WHERE album.artist_id = artist.id AND album.name like "%%%s%%"(Ry(R[Ru((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytsearch_albums_by_nameÒs cCsd|}t|ƒS(Ns“SELECT artist.id, artist.name, album.id, album.name FROM artist, album WHERE album.artist_id = artist.id AND year like "%%%s%%"(Ry(tyearRu((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytsearch_albums_by_yearØs cCsd|}t|ƒS(Ns”SELECT artist.id, artist.name, album.id, album.name FROM artist, album WHERE album.artist_id = artist.id AND genre like "%%%s%%"(Ry(tgenreRu((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytsearch_albums_by_genreÞs cCsd|}t|ƒS(Ns7SELECT artist.id artist_id, artist.name artist_name, album.id album_id, album.name album_name, music.name music_name FROM artist, album, music WHERE album.artist_id = artist.id AND music.album_id = album.id AND upper(music.name) like "%%%s%%" ORDER BY artist.name, album.name, music.name(Ry(R[Ru((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytsearch_musics_by_nameäs s~/mp3cCs¹y$ddkl}ddkl}Wntj odSX|idd}tddƒtd d ƒiƒ}t ƒ\}}|i |ƒt i i |ƒoti|ƒnt i|ƒxít|tƒD]Ü\}} xÍ| D]Å} t i i|| ƒ} | i|ƒ} | d iƒ} | d jotd | ƒqÞny|| d|ƒ}Wn$tj otd | ƒqÞnXt|| ƒpqÞn|id|ddƒ|iƒ}|p&|id|ddƒ|i}n |d}|id|dd|fƒ|iƒ}|pfd}|idƒo|dd}n|id|dd||ddd |fƒ|i}n |d}g}|idD]}|t|ƒqž~}t i id||fƒpTg}t|ƒdjo"t |dd||f|ƒq+|| ƒ}g}x6|i!ƒD](}|d djo|i"|ƒq1q1Wt|ƒdjo·t|ƒdjoDxW|D]5}|i#|ƒi$djo|i#|ƒi%}qŠqŠWn|i#|dƒi%}d||f}t|dƒ}|i&|ƒ|i'ƒt |||ƒq+nt i i(| ƒ}|id|ddi)dd ƒ||d!d|i*i+|i*i,| d|fƒ|i-ƒt| ƒqÞWqËW|i'ƒdS("Niÿÿÿÿ(tMP3(tEasyID3iR s/cacheRRs(../html/jukebox/config/create_tables.sqltriýÿÿÿtmp3s)(NOTMP3) The file isn't an audio file: %stID3s*SELECT id FROM artist WHERE name LIKE "%s"RCis'INSERT INTO artist (name) VALUES ("%s")sJSELECT album.id FROM album WHERE album.name LIKE "%s" AND artist_id = "%s"RBR~sPINSERT INTO album (name, artist_id, year, genre) VALUES ("%s", "%s", "%s", "%s")RDit cover_sizes %s/%.4i.jpgtAPICiuxINSERT INTO music (name, album_id, track, length, bitrate, path, size) VALUES ("%s", "%s", "%s", "%s", "%s", "%s", "%s")RAt"s'RE(.t mutagen.mp3Rtmutagen.easyid3R‚t ImportErrorRRGRtreadR)t executescriptRRLtisdirtshutiltrmtreetmkdirRWRHR"Rtlowert ExceptionRNR_Rit lastrowidtNoneRItinttexistsRR@RtappendtgetttypetdataR#R$tgetsizeRtinfotlengthtbitratetcommit(tconfigtmediadirRR‚t CACHE_PATHRuR-R,tdirtfilesRQtfullpatht relativepathtextRKRCRBR~RRR>timg_listtft apic_keysRtapict apic_path((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pytmainîs–          (  ."     I t__main__tpRGs"../html/jukebox/config/jukebox.logRƒtviewRCtststatsRBtmusictsearchtqttRaRdR|tyearsR~tgenresRgtsettingstthemeR†t album_viewt flash_playert url_musictmp3_dirtaboutRLRmt total_time(i€i€(ER/RtglobRTRttypestcgitcgitbtenablet pysqlite2RR(t htmljukeboxtreloadtsetdefaultencodingtobjectRR)R3R@RNRGRJRWRbReRhRjRlRnRoRwRyRzR{R}RR€R®R&R¡Rt htmlheadert FieldStoragetformtgetvaluetpageRRthtmllogRIRkRat letter_statst htmlartistsRdt htmlalbumsRgt htmlmusicstcriteriaRšRxt htmlsearchRR%t htmlsettingst htmlaboutt htmlindext htmlfooter(((s</home/bunghole/jukebox.bunghole.com.br/demo/cgi-bin/index.pyts¨H                    f         !              "