public Mp3Split(CueSheet s) { int error = 0; _sheet = s; _mp3_state = mp3splt_new_state(out error); error = mp3splt_find_plugins(_mp3_state); Hyena.Log.Information("mp3splt: find_plugins result:" + error); mp3splt_set_int_option(_mp3_state, Mp3SpltOptions.SPLT_OPT_SET_FILE_FROM_CUE_IF_FILE_TAG_FOUND, 1); mp3splt_set_int_option(_mp3_state, Mp3SpltOptions.SPLT_OPT_OUTPUT_FILENAMES, (int)SpltOutputFileNamesOptions.SPLT_OUTPUT_FORMAT); mp3splt_set_oformat(_mp3_state, "@A - @b - @n - @t", out error); _file_format = "@A - @b - @n - @t"; mp3splt_put_cue_splitpoints_from_file(_mp3_state, s.cueFile(), out error); mp3splt_set_default_genre_tag(_mp3_state, s.genre()); int count, ctags; IntPtr pointarray = mp3splt_get_splitpoints(_mp3_state, out count, out error); IntPtr tagarray = mp3splt_get_tags(_mp3_state, out ctags, out error); Hyena.Log.Information("count=" + count + ", ctags=" + ctags); { int i; _tracks.Clear(); int N = (count < ctags) ? count : ctags; for (i = 0; i < N; i++) { _tracks.Add(new Mp3SplitTrack(pointarray, tagarray, i)); } } }
public void seekSong(int i) { Hyena.Log.Information("SeekSong called " + i); try { CueSheet sheet = MySource.getSheet(); if (sheet.Count == 0) { if (_selected != null) { loadCueSheet(_selected); } } CueSheetEntry e = sheet.entry(i); _song_id = e.id(); if (_song_file != e.file()) { ServiceManager.PlayerEngine.Open(e); ServiceManager.PlayerEngine.Play(); _song_file = e.file(); } double offset = e.offset(); //ServiceManager.PlayerEngine.SetCurrentTrack(e); _position = (uint)(offset * 1000.0); _set_position = true; mscount = chgcount - (1000 / timeout); } catch (SystemException ex) { Hyena.Log.Information(ex.ToString()); } }
public void PlayPlayList(CS_PlayList pls) { Hyena.Log.Information("Playing playlist " + pls.PlsName); CueSheet s = pls.GetCueSheet(); loadCueSheet(s); }
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(); } } }
public CueSheetEntry(CueSheet s, string file, String artId, int nr, int cnt, string title, string performer, string album, double offset) : base() { _file = file; _title = title; _performer = performer; _offset = offset; BeginOffset = (int)(offset * 1000.0); // milliseconds EndOffset = -1; _length = new TimeSpan(0); _parent = s; _art = artId; base.AlbumArtist = performer; base.TrackTitle = title; base.AlbumTitle = album; base.ArtistName = performer; base.TrackNumber = nr; base.TrackCount = cnt; base.DiscNumber = 1; base.CanPlay = true; base.CanSaveToDatabase = false; base.Duration = new System.TimeSpan(0, 0, 10, 0); base.Uri = new Hyena.SafeUri(_file, false); }
void HandleAviewSelectionChanged(object sender, EventArgs e) { int index = ((Selection)sender).FirstIndex; CS_AlbumInfo a = (CS_AlbumInfo)MySource.getAlbumModel()[index]; _selected = a.getSheet(); }
private void fill(string cwd) { Hyena.Log.Information("Scanning directory " + cwd); string [] dirs = Directory.GetDirectories(cwd, "*"); string [] sheets = Directory.GetFiles(cwd, "*.cue"); foreach (string dir in dirs) { _fill_dirs.Push(dir); } foreach (string sheet in sheets) { _fill_cues.Push(sheet); } GLib.Timeout.Add(10, delegate() { if (_fill_canceled) { return(false); } int i = 0; while (i < 1 && _fill_cues.Count > 0) { string sheet = _fill_cues.Pop(); string bn = Tools.basename(sheet); if (bn != "") { if (bn.Substring(0, 1) != ".") { CueSheet cs = new CueSheet(sheet, cwd, basedir); getSheets().Add(cs); } } i += 1; _fill_count += 1; } filling.Text = "scanning " + basedir + "..." + _fill_count + " files, " + _fill_dir_count + " directories"; if (_fill_cues.Count == 0) { if (_fill_dirs.Count > 0) { string dir = _fill_dirs.Pop(); _fill_dir_count += 1; fill(dir); } else { _fill_ready = true; } return(false); } else { return(true); } }); }
public void EditSheet(CueSheet s) { Hyena.Log.Information(s.cueFile()); CueSheetEditor edt = new CueSheetEditor(s); edt.Do(); MySource.getAlbumModel().Reload(); MySource.getArtistModel().Reload(); }
private void setLatinTags(CueSheet s) { int i, N; for (i = 0, N = s.nEntries(); i < N; i++) { ProgressCurrentTrack = i + 1; setLatinTag(i, s, s.entry(i)); } }
public void OpenContainingFolder(CS_AlbumInfo a) { CueSheet s = a.getSheet(); string path = System.IO.Path.GetDirectoryName(s.cueFile()); if (Banshee.IO.Directory.Exists(path)) { System.Diagnostics.Process.Start(path); } }
public void loadCueSheet(CueSheet s) //,Gtk.ListStore store) { { MySource.setSheet(s); CueSheet sheet = MySource.getSheet(); store.SetSheet(sheet); store.Reload(); reLoad(); Hyena.Log.Information("Setting column sizes for " + s.id()); setColumnSizes(s); }
public CS_ComposerInfo(CueSheet s) { _sheet = s; if (s != null) { Name = s.composer(); } else { Name = "<All Composers>"; } }
public CS_ArtistInfo(CueSheet s) { _sheet = s; if (s != null) { base.Name = s.performer(); } else { base.Name = "<All Artists>"; } }
public CueSheet GetCueSheet() { CueSheet s = new CueSheet(); s.SetTitle(_name); s.SheetKind = CueSheet.Kind.PlayList; foreach (CS_PlayListEntry ple in _playlist) { s.AddEntry(ple.GetCueSheetEntry()); } return(s); }
public CS_AlbumInfo(CueSheet s) { _sheet = s; if (s == null) { base.ArtistName = "none"; base.Title = "none"; } else { base.ArtistName = s.performer(); base.Title = s.title(); base.ArtworkId = s.getArtId(); } }
public void setColumnSizes(CueSheet s) { int N = view.ColumnController.Count; int i; for (i = 0; i < N; i++) { _set_column_sizes += 1; CS_Column col = (CS_Column)view.ColumnController[i]; double w = (i == 0) ? 0.05 : 0.16; if (s != null) { w = MySource.getColumnWidth(col.id(), s.id()); } col.Width = w; } }
protected override bool OnPopupMenu() { Gtk.Menu mnu = new Gtk.Menu(); Gtk.ImageMenuItem play = new Gtk.ImageMenuItem(Gtk.Stock.MediaPlay, null); play.Activated += delegate(object sender, EventArgs a) { _view.PlayAlbum((CS_AlbumInfo)this.Model[Selection.FirstIndex]); }; Gtk.ImageMenuItem edit = new Gtk.ImageMenuItem(Gtk.Stock.Edit, null); edit.Activated += delegate(object sender, EventArgs a) { _view.EditSheet(((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet()); }; Gtk.ImageMenuItem show_file = new Gtk.ImageMenuItem("Show in filesystem"); show_file.Image = new Gtk.Image(Gtk.Stock.Directory, Gtk.IconSize.Menu); show_file.Activated += delegate(object sender, EventArgs a) { _view.OpenContainingFolder((CS_AlbumInfo)this.Model[Selection.FirstIndex]); }; mnu.Append(play); mnu.Append(new Gtk.SeparatorMenuItem()); mnu.Append(edit); mnu.Append(show_file); CueSheet s = ((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet(); if (Mp3Split.DllPresent()) { if (Mp3Split.IsSupported(s.musicFileName())) { Gtk.ImageMenuItem split = new Gtk.ImageMenuItem("Split & Write to location"); split.Image = new Gtk.Image(Gtk.Stock.Convert, Gtk.IconSize.Menu); split.Activated += delegate(object sender, EventArgs a) { _view.MusicFileToDevice(((CS_AlbumInfo)this.Model[Selection.FirstIndex]).getSheet()); }; mnu.Append(split); } } mnu.ShowAll(); mnu.Popup(); return(false); }
public Boolean previous() { CueSheet sheet = MySource.getSheet(); if (sheet == null) { return(false); } if (index > 0) { index -= 1; } else { index = sheet.nEntries() - 1; } seekSong(index); return(true); }
public Boolean next() { CueSheet sheet = MySource.getSheet(); if (sheet == null) { return(false); } if (index < sheet.nEntries() - 1) { index += 1; } else { index = 0; } seekSong(index); return(true); }
private void FillLibrary(string cwd) { string [] dirs = Directory.GetDirectories(cwd, "*"); string [] sheets = Directory.GetFiles(cwd, "*.cue"); string ddir = basedir + "/.banshee"; if (!Directory.Exists(ddir)) { Directory.CreateDirectory(ddir); } foreach (string sheet in sheets) { CueSheet cs = new CueSheet(sheet, cwd, basedir); ImportSheet(cs); Thread.Sleep(500); } foreach (string dir in dirs) { FillLibrary(dir); } }
public void Save() { string pls = ""; string sep = ""; Hyena.Log.Information("Playlist=" + _playlist); foreach (CS_PlayListEntry ple in _playlist) { Hyena.Log.Information("ple=" + ple); CueSheetEntry e = ple.GetCueSheetEntry(); Hyena.Log.Information("e=" + e); CueSheet s = e.getCueSheet(); Hyena.Log.Information("sheet=" + s + ", entry=" + e); string id = s.id(); string e_id = e.id(); string entry = "cuesheet=" + id + "%%%entry=" + e_id; pls += sep; pls += entry; sep = "#@%@#"; } _db.Set("playlist:" + _name, pls); }
public CueSheetEntry() { _file=""; _title=""; _performer=""; _offset=0.0; BeginOffset=0; EndOffset=-1; _length=new TimeSpan(0); _parent=null; _art=""; base.AlbumArtist=""; base.TrackTitle=""; base.AlbumTitle=""; base.ArtistName=""; base.TrackNumber=0; base.TrackCount=0; base.DiscNumber=0; base.CanPlay=true; base.CanSaveToDatabase=false; base.Duration=new System.TimeSpan(0,0,10,0); base.Uri=new Hyena.SafeUri("",false); }
public CueSheetEntry() { _file = ""; _title = ""; _performer = ""; _offset = 0.0; BeginOffset = 0; EndOffset = -1; _length = new TimeSpan(0); _parent = null; _art = ""; base.AlbumArtist = ""; base.TrackTitle = ""; base.AlbumTitle = ""; base.ArtistName = ""; base.TrackNumber = 0; base.TrackCount = 0; base.DiscNumber = 0; base.CanPlay = true; base.CanSaveToDatabase = false; base.Duration = new System.TimeSpan(0, 0, 10, 0); base.Uri = new Hyena.SafeUri("", false); }
public void reLoad() { index = 0; try { CueSheet sheet = MySource.getSheet(); //ServiceManager.PlayerEngine.SetAccurateSeek(true); CueSheetEntry e = sheet.entry(index); _song_id = e.id(); ServiceManager.PlayerEngine.Open(e); ServiceManager.PlayerEngine.Play(); if (ServiceManager.PlaybackController.Source != MySource) { ServiceManager.PlaybackController.Source = MySource; } if (ServiceManager.PlaybackController.NextSource != MySource) { ServiceManager.PlaybackController.NextSource = MySource; } //ServiceManager.PlaybackController.SetSeekMode (true); } catch (SystemException ex) { Hyena.Log.Information(ex.ToString()); } mscount = chgcount - 1; }
//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 (); }
public CueSheetEditor(CueSheet s) { _sheet=s; }
public void EditSheet(CueSheet s) { Hyena.Log.Information (s.cueFile ()); CueSheetEditor edt=new CueSheetEditor(s); edt.Do (); MySource.getAlbumModel ().Reload (); MySource.getArtistModel ().Reload (); }
public void load(CueSheet s) { load (s._cuefile,s._directory,s._basedir); }
public CueSheetsSource() : base(AddinManager.CurrentLocalizer.GetString("CueSheets"), AddinManager.CurrentLocalizer.GetString("CueSheets"), //"cuesheets", sort_order) //, //"hod-cuesheets-2013-01-06") { Hyena.Log.Information("CueSheetsSouce init"); DbConnection = ServiceManager.DbConnection; TM_Provider = DatabaseTrackInfo.Provider; _track_info_db = new CS_TrackInfoDb(DbConnection); _sheet = new CueSheet(); _sheets = new CueSheetCollection(); _view = new CueSheetsView(this); Properties.Set <ISourceContents> ("Nereid.SourceContents", _view); Properties.SetString("Icon.Name", "cueplay"); Hyena.Log.Information("CueSheets source has been instantiated."); Properties.Set <string> ("SearchEntryDescription", Catalog.GetString("Search albums and tracks")); try { Properties.SetString("GtkActionPath", "/CueSheetsPopup"); _actions = new CS_Actions(this); Hyena.Log.Information(_actions.ToString()); } catch (System.Exception ex) { Hyena.Log.Information(ex.ToString()); } InterfaceActionService action_service = ServiceManager.Get <InterfaceActionService> (); try { _track_search = new Gtk.CheckButton("Search Tracks"); _track_search.Clicked += delegate(object sender, EventArgs args) { this.DoFilter(); }; Gtk.Toolbar header_toolbar = (Gtk.Toolbar)action_service.UIManager.GetWidget("/HeaderToolbar"); int i, N, k; for (i = 0, k = -1, N = header_toolbar.NItems; i < N; i++) { Gtk.Widget w = header_toolbar.GetNthItem(i).Child; if (w != null) { if (w.GetType() == typeof(Banshee.Gui.Widgets.ConnectedVolumeButton)) { k = i; } } } if (k >= 0) { Hyena.Log.Information("Toolitem itm"); Gtk.ToolItem itm = new Gtk.ToolItem(); Hyena.Log.Information("Add cbk"); itm.Add(_track_search); Hyena.Log.Information("Insert cbk"); header_toolbar.Insert(itm, k); itm.Show(); } } catch (System.Exception ex) { Hyena.Log.Error(ex.ToString()); } Gtk.Menu viewMenu = (action_service.UIManager.GetWidget("/MainMenu/ViewMenu") as Gtk.MenuItem).Submenu as Gtk.Menu; _menuItem = new Gtk.MenuItem(Catalog.GetString("_Change Album View")); _menuItem.Activated += delegate { _view.ToggleGrid(); }; viewMenu.Insert(_menuItem, 2); _sep = new Gtk.SeparatorMenuItem(); viewMenu.Insert(_sep, 3); }
public void setColumnSizes(CueSheet s) { int N=view.ColumnController.Count; int i; for(i=0;i<N;i++) { _set_column_sizes+=1; CS_Column col=(CS_Column) view.ColumnController[i]; double w=(i==0) ? 0.05 : 0.16; if (s!=null) { w=MySource.getColumnWidth (col.id(),s.id ()); } col.Width=w; } }
private void FillLibrary(string cwd) { string [] dirs=Directory.GetDirectories(cwd, "*"); string [] sheets=Directory.GetFiles (cwd,"*.cue"); string ddir=basedir+"/.banshee"; if (!Directory.Exists(ddir)) { Directory.CreateDirectory(ddir); } foreach (string sheet in sheets) { CueSheet cs=new CueSheet(sheet,cwd,basedir); ImportSheet(cs); Thread.Sleep (500); } foreach (string dir in dirs) { FillLibrary (dir); } }
public CS_MusicToDevice(CueSheet s) { _sheet=s; }
public Mp3Split(CueSheet s) { int error=0; _sheet=s; _mp3_state=mp3splt_new_state (out error); error=mp3splt_find_plugins (_mp3_state); Hyena.Log.Information ("mp3splt: find_plugins result:"+error); mp3splt_set_int_option(_mp3_state,Mp3SpltOptions.SPLT_OPT_SET_FILE_FROM_CUE_IF_FILE_TAG_FOUND,1); mp3splt_set_int_option(_mp3_state,Mp3SpltOptions.SPLT_OPT_OUTPUT_FILENAMES,(int) SpltOutputFileNamesOptions.SPLT_OUTPUT_FORMAT); mp3splt_set_oformat(_mp3_state,"@A - @b - @n - @t",out error); _file_format="@A - @b - @n - @t"; mp3splt_put_cue_splitpoints_from_file(_mp3_state,s.cueFile (),out error); mp3splt_set_default_genre_tag(_mp3_state,s.genre ()); int count,ctags; IntPtr pointarray=mp3splt_get_splitpoints(_mp3_state,out count,out error); IntPtr tagarray=mp3splt_get_tags (_mp3_state,out ctags,out error); Hyena.Log.Information ("count="+count+", ctags="+ctags); { int i; _tracks.Clear (); int N=(count<ctags) ? count : ctags; for(i=0;i<N;i++) { _tracks.Add (new Mp3SplitTrack(pointarray,tagarray,i)); } } }
public CueSheetEntry(CueSheet s,string file,String artId,int nr,int cnt,string title,string performer,string album,double offset) : base() { _file=file; _title=title; _performer=performer; _offset=offset; BeginOffset=(int) (offset*1000.0); // milliseconds EndOffset=-1; _length=new TimeSpan(0); _parent=s; _art=artId; base.AlbumArtist=performer; base.TrackTitle=title; base.AlbumTitle=album; base.ArtistName=performer; base.TrackNumber=nr; base.TrackCount=cnt; base.DiscNumber=1; base.CanPlay=true; base.CanSaveToDatabase=false; base.Duration=new System.TimeSpan(0,0,10,0); base.Uri=new Hyena.SafeUri(_file,false); }
public void MusicFileToDevice(CueSheet s) { CS_MusicToDevice mtd = new CS_MusicToDevice(s); mtd.Do(); }
public void setSheet(CueSheet s) { _sheet=s; }
//, //"hod-cuesheets-2013-01-06") public CueSheetsSource() : base(AddinManager.CurrentLocalizer.GetString ("CueSheets"), AddinManager.CurrentLocalizer.GetString ("CueSheets"), //"cuesheets", sort_order) { Hyena.Log.Information ("CueSheetsSouce init"); DbConnection=ServiceManager.DbConnection; TM_Provider=DatabaseTrackInfo.Provider; _track_info_db=new CS_TrackInfoDb(DbConnection); _sheet=new CueSheet(); _sheets=new CueSheetCollection(); _view=new CueSheetsView(this); Properties.Set<ISourceContents> ("Nereid.SourceContents", _view); Properties.SetString ("Icon.Name", "cueplay"); Hyena.Log.Information ("CueSheets source has been instantiated."); Properties.Set<string> ("SearchEntryDescription", Catalog.GetString ("Search albums and tracks")); try { Properties.SetString("GtkActionPath","/CueSheetsPopup"); _actions = new CS_Actions (this); Hyena.Log.Information(_actions.ToString()); } catch (System.Exception ex) { Hyena.Log.Information(ex.ToString ()); } InterfaceActionService action_service = ServiceManager.Get<InterfaceActionService> (); try { _track_search=new Gtk.CheckButton("Search Tracks"); _track_search.Clicked+=delegate(object sender,EventArgs args) { this.DoFilter(); }; Gtk.Toolbar header_toolbar = (Gtk.Toolbar) action_service.UIManager.GetWidget ("/HeaderToolbar"); int i,N,k; for(i=0,k=-1,N=header_toolbar.NItems;i<N;i++) { Gtk.Widget w=header_toolbar.GetNthItem(i).Child; if (w!=null) { if (w.GetType()==typeof(Banshee.Gui.Widgets.ConnectedVolumeButton)) { k=i; } } } if (k>=0) { Hyena.Log.Information("Toolitem itm"); Gtk.ToolItem itm=new Gtk.ToolItem(); Hyena.Log.Information ("Add cbk"); itm.Add (_track_search); Hyena.Log.Information ("Insert cbk"); header_toolbar.Insert (itm,k); itm.Show (); } } catch (System.Exception ex) { Hyena.Log.Error (ex.ToString ()); } Gtk.Menu viewMenu = (action_service.UIManager.GetWidget ("/MainMenu/ViewMenu") as Gtk.MenuItem).Submenu as Gtk.Menu; _menuItem = new Gtk.MenuItem (Catalog.GetString ("_Change Album View")); _menuItem.Activated += delegate { _view.ToggleGrid(); }; viewMenu.Insert (_menuItem, 2); _sep=new Gtk.SeparatorMenuItem(); viewMenu.Insert (_sep,3); }
public CS_MusicToDevice(CueSheet s) { _sheet = s; }
public void loadCueSheet(CueSheet s) { //,Gtk.ListStore store) { MySource.setSheet(s); CueSheet sheet=MySource.getSheet (); store.SetSheet(sheet); store.Reload (); reLoad (); Hyena.Log.Information ("Setting column sizes for "+s.id ()); setColumnSizes (s); }
//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(); }
public void MusicFileToDevice(CueSheet s) { CS_MusicToDevice mtd=new CS_MusicToDevice(s); mtd.Do (); }
private void setLatinTags(CueSheet s) { int i,N; for(i=0,N=s.nEntries ();i<N;i++) { ProgressCurrentTrack=i+1; setLatinTag (i,s,s.entry (i)); } }
private void fill(string cwd) { Hyena.Log.Information ("Scanning directory "+cwd); string [] dirs=Directory.GetDirectories(cwd, "*"); string [] sheets=Directory.GetFiles (cwd,"*.cue"); foreach (string dir in dirs) { _fill_dirs.Push (dir); } foreach (string sheet in sheets) { _fill_cues.Push (sheet); } GLib.Timeout.Add (10,delegate() { if (_fill_canceled) { return false; } int i=0; while(i<1 && _fill_cues.Count>0) { string sheet=_fill_cues.Pop (); string bn=Tools.basename (sheet); if (bn!="") { if (bn.Substring (0,1)!=".") { CueSheet cs=new CueSheet(sheet,cwd,basedir); getSheets().Add (cs); } } i+=1; _fill_count+=1; } filling.Text="scanning "+basedir+"..."+_fill_count+" files, "+_fill_dir_count+" directories"; if (_fill_cues.Count==0) { if (_fill_dirs.Count>0) { string dir=_fill_dirs.Pop (); _fill_dir_count+=1; fill (dir); } else { _fill_ready=true; } return false; } else { return true; } }); }
public void setSheet(CueSheet s) { _sheet = s; }
void HandleAviewSelectionChanged(object sender, EventArgs e) { int index=((Selection) sender).FirstIndex; CS_AlbumInfo a=(CS_AlbumInfo) MySource.getAlbumModel ()[index]; _selected=a.getSheet (); }
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 (); } } }
public CueSheetEditor(CueSheet s) { _sheet = s; }
private int chgcount = 3000 / 100; // every 3 seconds //private CueSheetEntry _playing=null; public bool PositionDisplay() { if (ServiceManager.PlaybackController.Source == MySource) { CueSheet sheet = MySource.getSheet(); if (sheet != null) { mscount += 1; if (mscount > chgcount) { mscount = 0; } // Position if necessary if (_set_position) { _set_position = false; _positioning = true; ServiceManager.PlayerEngine.Position = _position; } // Do nothing while seeking uint pos = ServiceManager.PlayerEngine.Position; double p = ((double)pos) / 1000.0; if (_positioning && pos <= _position) { //Hyena.Log.Information ("seek="+_position+", pos="+pos); // do nothing } else { _positioning = false; // Track number int i = sheet.searchIndex(_song_id, p); if (i != index && i >= 0) { // Handle repeat track if (ServiceManager.PlaybackController.RepeatMode == PlaybackRepeatMode.RepeatSingle) { seekSong(index); } else if (sheet.SheetKind == CueSheet.Kind.PlayList) { index = i; seekSong(i); } // Every 2 seconds if (mscount == 0) { Hyena.Log.Information("Found index i=" + i + ", songid=" + _song_id); index = i; CueSheetEntry e = sheet.entry(index); Hyena.Log.Information("current entry: " + e); //ServiceManager.PlayerEngine.SetCurrentTrack (e); } } if (mscount == 0 && index >= 0) { Hyena.Log.Information("mscount=" + mscount + ", index=" + index); //view.ScrollTo(index); view.Selection.QuietUnselect(view.Selection.FirstIndex); view.Selection.Select(index); } } } } return(true); }