Пример #1
0
 void writeEntry(StreamWriter wrt, CueSheetEntry e, int i)
 {
     indent = "  ";
     wrtl_track(wrt, i + 1);
     indent = "    ";
     wrtl(wrt, "title", e.title());
     wrtl(wrt, "performer", e.performer());
     wrtl(wrt, "piece", e.getPiece(), true);
     wrtl(wrt, "composer", e.getComposer(), true);
     wrtl_index(wrt, 1, e.offset());
 }
 void writeEntry(StreamWriter wrt,CueSheetEntry e,int i)
 {
     indent="  ";
     wrtl_track(wrt,i+1);
     indent="    ";
     wrtl (wrt,"title",e.title ());
     wrtl (wrt,"performer",e.performer ());
     wrtl (wrt,"piece",e.getPiece (),true);
     wrtl (wrt,"composer",e.getComposer (),true);
     wrtl_index(wrt,1,e.offset ());
 }
Пример #3
0
        //private Stack<DatabaseTrackInfo> stk=new Stack<DatabaseTrackInfo>();

        public void ImportSheet(CueSheet s)
        {
            if (import_manager == null)
            {
                try {
                    import_manager = new LibraryImportManager(false);

                    /*import_manager.ImportResult+=delegate(object sender,DatabaseImportResultArgs args) {
                     *      DatabaseTrackInfo trk=args.Track;
                     *      stk.Push (trk);
                     * };*/
                } catch (Exception ex) {
                    Hyena.Log.Error(ex.ToString());
                }
            }

            Hyena.Log.Debug("Importsheet: Starting transaction");
            int i, N;

            for (i = 0, N = s.nEntries(); i < N; i++)
            {
                try {
                    CueSheetEntry e    = s.entry(i);
                    string        file = e.file();
                    string        uuid = Regex.Replace(e.id(), "\\s", "_");
                    string        ext  = ".mp3";

                    string uid = Guid.NewGuid().ToString();
                    string u1  = uid.Substring(0, 1);
                    string u2  = uid.Substring(0, 2);
                    string dir = basedir + "/.banshee/" + u1;
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    dir += "/" + u2;
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    uuid = dir + "/" + uuid + ext;

                    UnixFileInfo f = new UnixFileInfo(file);
                    if (File.Exists(uuid))
                    {
                        File.Delete(uuid);
                    }
                    //f.CreateLink (uuid);
                    f.CreateSymbolicLink(uuid);

                    DatabaseTrackInfo trk = import_manager.ImportTrack(uuid);
                    //File.Delete (uuid);

                    /*if (trk==null) {
                     *      Hyena.Log.Warning ("track = null (file="+e.file ()+")");
                     *      if (stk.Count>0) { trk=stk.Pop (); }
                     * }*/

                    if (trk == null)
                    {
                        Hyena.Log.Error("track = null (file=" + e.file() + ")");
                    }
                    else
                    {
                        Hyena.Log.Information("track!=null (file=" + e.file() + ")");
                        //MySource.DbConnection.BeginTransaction();
                        trk.PartOfCue    = 1;
                        trk.CueAudioFile = e.file();
                        trk.AlbumTitle   = s.title();
                        //trk.Album=s.title ();
                        trk.AlbumArtist = s.performer();
                        trk.Composer    = (e.Composer == "") ? s.composer() : e.Composer;
                        //trk.ArtworkId=s.getArtId ();
                        //trk.Artist=
                        trk.ArtistName  = (e.performer() == "") ? s.performer() : e.performer();
                        trk.TrackTitle  = e.title();
                        trk.TrackNumber = i + 1;
                        trk.Genre       = s.genre();
                        trk.BeginOffset = e.BeginOffset;
                        trk.EndOffset   = e.EndOffset;
                        //trk.Uri=trk.CueAudioUri;
                        //trk.MediaAttributes = TrackMediaAttributes.ExternalResource;
                        //trk.PrimarySource = ServiceManager.SourceManager.MusicLibrary;

                        trk.Save();
                        //MySource.DbConnection.CommitTransaction();
                    }
                } catch (Exception ex) {
                    Hyena.Log.Error(ex.ToString());
                }
            }
            import_manager.NotifyAllSources();
        }
Пример #4
0
        public override void Reload()
        {
            _filteredList.Clear();
            List <CueSheet> s = MySource.getSheets();
            int             i, N;
            string          artist = "";

            if (_artist != null)
            {
                artist = Loosely.prepare(_artist.Name);
            }
            string composer = "";

            if (_composer != null)
            {
                composer = Loosely.prepare(_composer.Name);
            }
            for (i = 0, N = s.Count; i < N; i++)
            {
                bool do_add = true;
                if (_genre != null)
                {
                    if (s[i].genre() != _genre.Genre)
                    {
                        do_add = false;
                    }
                }
                if (_artist != null && do_add)
                {
                    if (!Loosely.eqp(artist, s[i].performer()))
                    {
                        do_add = false;
                    }
                }
                if (_composer != null && do_add)
                {
                    if (!Loosely.eqp(composer, s[i].composer()))
                    {
                        do_add = false;
                    }
                }
                if (_album_search != null && do_add)
                {
                    if (!s[i].title().ToLower().Contains(_album_search) &&
                        !s[i].performer().ToLower().Contains(_album_search) &&
                        !s[i].composer().ToLower().Contains(_album_search))
                    {
                        if (_also_in_tracks)
                        {
                            CueSheet q = s[i];
                            int      k, M;
                            bool     can_add = false;
                            for (k = 0, M = q.nEntries(); k < M && !can_add; k++)
                            {
                                CueSheetEntry e = q.entry(k);
                                if (e.title().ToLower().Contains(_album_search) ||
                                    e.performer().ToLower().Contains(_album_search) ||
                                    e.getComposer().ToLower().Contains(_album_search))
                                {
                                    can_add = true;
                                }
                            }
                            do_add = can_add;
                        }
                        else
                        {
                            do_add = false;
                        }
                    }
                }

                if (do_add)
                {
                    _filteredList.Add(new CS_AlbumInfo(s[i]));
                }
            }
            _filteredList.Sort(new CS_AlbumInfo.Comparer());
            base.RaiseReloaded();
        }
 private void setLatinTag(int track,CueSheet s,CueSheetEntry e)
 {
     string fn=_file_format;
     fn=fn.Replace ("@A",s.performer());
     fn=fn.Replace ("@b",s.title ());
     fn=fn.Replace ("@n",(track+1).ToString ());
     fn=fn.Replace ("@t",e.title ());
     fn=_directory+"/"+fn+".mp3";
     Hyena.Log.Information ("file to convert:"+fn);
     if (File.Exists(fn)) {
         TagLib.File file=TagLib.File.Create(fn);
         if (file==null) {
             Hyena.Log.Error ("Cannot create taglib file for "+fn);
             return;
         } else {
             Hyena.Log.Information("Setting tags for "+fn);
             file.Tag.Album=s.title ();
             file.Tag.AlbumArtists=new string[]{s.performer ()};
             file.Tag.Composers=new string[]{s.composer ()};
             file.Tag.Genres=new string[]{s.genre ()};
             file.Tag.Title=e.title ();
             file.Tag.Track=(uint) track+1;
             file.Tag.Performers=new string[]{e.performer ()};
             file.Save ();
         }
     }
 }