public UserSyncController (Api api, string userIdentifier, RdioObjectStore sharedObjectStore) { if (api == null) throw new ArgumentNullException (nameof (api)); if (String.IsNullOrEmpty (userIdentifier)) throw new ArgumentException ("must not be null or empty", nameof (userIdentifier)); if (sharedObjectStore == null) throw new ArgumentNullException (nameof (sharedObjectStore)); UserIdentifier = userIdentifier; ObjectStore = sharedObjectStore; this.api = api; api.CancellationToken = CancellationToken; }
public UserSyncController(Api api, string userIdentifier, RdioObjectStore sharedObjectStore) { if (api == null) { throw new ArgumentNullException(nameof(api)); } if (String.IsNullOrEmpty(userIdentifier)) { throw new ArgumentException("must not be null or empty", nameof(userIdentifier)); } if (sharedObjectStore == null) { throw new ArgumentNullException(nameof(sharedObjectStore)); } UserIdentifier = userIdentifier; ObjectStore = sharedObjectStore; this.api = api; api.CancellationToken = CancellationToken; }
public int Main (IEnumerable<string> args) { var showHelp = false; var following = false; outputDir = Environment.CurrentDirectory; Console.WriteLine ("Conservatorio v{0} ({1}/{2}, {3})", BuildInfo.Version, BuildInfo.Branch, BuildInfo.Hash, BuildInfo.Date); Console.WriteLine (" by Aaron Bockover (@abock)"); Console.WriteLine (" http://conservator.io"); Console.WriteLine (); var optionSet = new OptionSet { "Usage: conservatorio [OPTIONS]+ USER [USER...]", "", "Fetch users' favorites and synced Rdio track metadata as well as all " + "favorited, owned, collaborated, and subscriped playlists metadata, " + "backing up all raw JSON data as exported by Rdio.", "", "More information: http://conservator.io", "", "Options:", { "o|output-dir=", "output all JSON data to files in {DIR} directory," + "defaulting to the current working directory", v => outputDir = v }, { "s|single-store", "when fetching data for multiple users, use a single shared object " + "store and persist all users in the same output file", v => sharedObjectStore = new RdioObjectStore () }, { "f|following", "also back up the data of all users a specified user is " + "following (non recursive)", v => following = true }, { "v|verbose", "be more verbose, particularly by showing exception stacktraces on error", v => verbose = true }, { "h|help", "show this help", v => showHelp = true } }; var users = optionSet.Parse (args); if (showHelp || users.Count == 0) { optionSet.WriteOptionDescriptions (Console.Out); return 1; } if (!Directory.Exists (outputDir)) { Console.Error.WriteLine ("error: output directory does not exist: {0}", outputDir); return 1; } api = new Api (); foreach (var user in users) SyncUser (user, following).Wait (); if (sharedObjectStore != null && userKeyStores.Count > 0) { var path = Path.Combine (outputDir, "Conservatorio_RdioExport.json"); Console.WriteLine ("Exporting data for {0} users ({1} total objects) to {2}...", userKeyStores.Count, sharedObjectStore.Count, path); new Exporter { ObjectStore = sharedObjectStore, UserKeyStores = userKeyStores }.Export (path); Console.WriteLine ("Done!"); } return 0; }
public UserSyncController(string userIdentifier, RdioObjectStore sharedObjectStore) : this(new Api(), userIdentifier, sharedObjectStore) { }
public UserSyncController (string userIdentifier, RdioObjectStore sharedObjectStore) : this (new Api (), userIdentifier, sharedObjectStore) { }
public int Main(IEnumerable <string> args) { var showHelp = false; var following = false; outputDir = Environment.CurrentDirectory; Console.WriteLine("Conservatorio v{0} ({1}/{2}, {3})", BuildInfo.Version, BuildInfo.Branch, BuildInfo.Hash, BuildInfo.Date); Console.WriteLine(" by Aaron Bockover (@abock)"); Console.WriteLine(" http://conservator.io"); Console.WriteLine(); var optionSet = new OptionSet { "Usage: conservatorio [OPTIONS]+ USER [USER...]", "", "Fetch users' favorites and synced Rdio track metadata as well as all " + "favorited, owned, collaborated, and subscriped playlists metadata, " + "backing up all raw JSON data as exported by Rdio.", "", "More information: http://conservator.io", "", "Options:", { "o|output-dir=", "output all JSON data to files in {DIR} directory," + "defaulting to the current working directory", v => outputDir = v }, { "s|single-store", "when fetching data for multiple users, use a single shared object " + "store and persist all users in the same output file", v => sharedObjectStore = new RdioObjectStore() }, { "f|following", "also back up the data of all users a specified user is " + "following (non recursive)", v => following = true }, { "v|verbose", "be more verbose, particularly by showing exception stacktraces on error", v => verbose = true }, { "h|help", "show this help", v => showHelp = true } }; var users = optionSet.Parse(args); if (showHelp || users.Count == 0) { optionSet.WriteOptionDescriptions(Console.Out); return(1); } if (!Directory.Exists(outputDir)) { Console.Error.WriteLine("error: output directory does not exist: {0}", outputDir); return(1); } api = new Api(); foreach (var user in users) { SyncUser(user, following).Wait(); } if (sharedObjectStore != null && userKeyStores.Count > 0) { var path = Path.Combine(outputDir, "Conservatorio_RdioExport.json"); Console.WriteLine("Exporting data for {0} users ({1} total objects) to {2}...", userKeyStores.Count, sharedObjectStore.Count, path); new Exporter { ObjectStore = sharedObjectStore, UserKeyStores = userKeyStores }.Export(path); Console.WriteLine("Done!"); } return(0); }