Beispiel #1
0
 public void Close(PluginCloseReason reason)
 {
     //MessageBox.Show("Close(" + reason + ")");
     lyricsReloaded.getLogger().info("Plugin disabled");
     lyricsReloaded.shutdown();
     lyricsReloaded = null;
 }
Beispiel #2
0
 public StaticLoader(LyricsReloaded lyricsReloaded, WebClient client, string urlTemplate, Pattern pattern)
 {
     this.lyricsReloaded = lyricsReloaded;
     this.urlTemplate    = urlTemplate;
     this.pattern        = pattern;
     this.client         = client;
 }
Beispiel #3
0
        public ProviderManager(LyricsReloaded lyricsReloaded)
        {
            this.lyricsReloaded = lyricsReloaded;
            logger          = lyricsReloaded.getLogger();
            providers       = new Dictionary <string, Provider>();
            loaderFactories = new Dictionary <string, LyricsLoaderFactory>();
            filters         = new Dictionary <string, Filter>();
            validators      = new Dictionary <string, Validator>();

            loadFilters();
            loadValidators();
        }
Beispiel #4
0
 public Provider(LyricsReloaded lyricsReloaded, string name, ushort quality, IDictionary <string, Variable> variables, FilterCollection postFilters, ValidationCollection validations, IDictionary <String, String> headers, LyricsLoader loader, RateLimit rateLimit = null)
 {
     this.lyricsReloaded = lyricsReloaded;
     this.name           = name;
     this.quality        = quality;
     this.variables      = variables;
     this.postFilters    = postFilters;
     this.validations    = validations;
     this.headers        = headers;
     this.loader         = loader;
     this.rateLimit      = rateLimit;
 }
Beispiel #5
0
        // Called from MusicBee
        public PluginInfo Initialise(IntPtr apiPtr)
        {
            //MessageBox.Show("Initialised(" + apiPtr + ")");
            musicBee = new MusicBeeApiInterface();
            musicBee.Initialise(apiPtr);

            info.PluginInfoVersion = PluginInfoVersion;
            info.Name                     = "Lyrics Reloaded!";
            info.Description              = "Lyrics loading done properly!";
            info.Author                   = "Phillip Schichtel <Quick_Wango>";
            info.TargetApplication        = "MusicBee";
            info.Type                     = PluginType.LyricsRetrieval;
            info.VersionMajor             = 1;
            info.VersionMinor             = 0;
            info.Revision                 = 1;
            info.MinInterfaceVersion      = 20;
            info.MinApiRevision           = 25;
            info.ReceiveNotifications     = ReceiveNotificationFlags.StartupOnly;
            info.ConfigurationPanelHeight = 0;

            try
            {
                lyricsReloaded = new LyricsReloaded(musicBee.Setting_GetPersistentStoragePath());
            }
            catch (Exception e)
            {
                MessageBox.Show("An error occurred during plugin startup: " + e.Message);
                throw;
            }

            try
            {
                lyricsReloaded.loadConfigurations();
            }
            catch (Exception e)
            {
                MessageBox.Show("An error occurred during plugin startup, send this file to the developer:\n\n" +
                                lyricsReloaded.getLogger().getFileInfo().FullName);
                lyricsReloaded.getLogger().error(e.Message);
                throw;
            }

            return(info);
        }
 public void setUp()
 {
     this.lr = new LyricsReloaded(".");
     lr.loadConfigurations();
 }
 public StaticLoaderFactory(LyricsReloaded lyricsReloaded)
 {
     this.lyricsReloaded = lyricsReloaded;
     webClient = new WebClient(lyricsReloaded, 5000);
 }
 public StaticLoader(LyricsReloaded lyricsReloaded, WebClient client, string urlTemplate, Pattern pattern)
 {
     this.lyricsReloaded = lyricsReloaded;
     this.urlTemplate = urlTemplate;
     this.pattern = pattern;
     this.client = client;
 }
Beispiel #9
0
        static int Main(string[] args)
        {
            Console.Title           = "LyricsReloaded!";
            Console.OutputEncoding  = Encoding.UTF8;
            Console.InputEncoding   = Encoding.UTF8;
            Console.CancelKeyPress += (sender, eventArgs) => Console.WriteLine("Bye!");

            String providerName = null;
            String artist       = null;
            String title        = null;
            String album        = null;

            int result = 0;

            int argc = args.Length;

            if (argc > 0)
            {
                providerName = args[0];
            }
            if (argc > 1)
            {
                artist = args[1];
            }
            if (argc > 2)
            {
                title = args[2];
            }
            if (argc > 3)
            {
                album = args[3];
            }

            LyricsReloaded lyricsReloaded = new LyricsReloaded(".");

            lyricsReloaded.loadConfigurations();

            lyricsReloaded.checkForNewVersion(newAvailable =>
            {
                if (newAvailable)
                {
                    Console.WriteLine();
                    Console.ForegroundColor = ConsoleColor.White;
                    Console.BackgroundColor = ConsoleColor.Red;
                    Console.Write("A new version is available!");
                    Console.ResetColor();
                    Console.WriteLine();
                }
            });

            if (String.IsNullOrWhiteSpace(providerName))
            {
                Console.WriteLine("The providers:");
                foreach (Provider p in lyricsReloaded.getProviderManager().getProviders())
                {
                    Console.WriteLine(" - {0}", p.getName());
                }
                Console.Write("Enter the provider: ");
                providerName = Console.ReadLine();
                if (providerName != null)
                {
                    providerName = providerName.Trim();
                }
            }
            if (String.IsNullOrWhiteSpace(artist))
            {
                Console.Write("Enter the artist: ");
                artist = Console.ReadLine();
                if (artist != null)
                {
                    artist = artist.Trim();
                }
            }
            if (String.IsNullOrWhiteSpace(title))
            {
                Console.Write("Enter the title: ");
                title = Console.ReadLine();
                if (title != null)
                {
                    title = title.Trim();
                }
            }


            Provider provider = lyricsReloaded.getProviderManager().getProvider(providerName);

            if (provider == null)
            {
                lyricsReloaded.getLogger().error("Provider {0} not found!", providerName);
                result = 1;
            }
            else
            {
                Console.Write("Provider {0}: ", providerName);
                try
                {
                    String lyrics = provider.getLyrics(artist, title, album);
                    if (String.IsNullOrWhiteSpace(lyrics))
                    {
                        Console.WriteLine("failed (not found)");
                        lyricsReloaded.getLogger().error("Lyrics not found!");
                    }
                    else
                    {
                        Console.WriteLine("success\n\n" + lyrics);
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("failed (internal error)");
                    Console.WriteLine(e.ToString());
                }
            }

            Console.WriteLine("\nPress any key to exit...");
            Console.ReadKey();

            return(result);
        }
Beispiel #10
0
 public StaticLoaderFactory(LyricsReloaded lyricsReloaded)
 {
     this.lyricsReloaded = lyricsReloaded;
     webClient           = new WebClient(lyricsReloaded, 5000);
 }
        public ProviderManager(LyricsReloaded lyricsReloaded)
        {
            this.lyricsReloaded = lyricsReloaded;
            logger = lyricsReloaded.getLogger();
            providers = new Dictionary<string, Provider>();
            loaderFactories = new Dictionary<string, LyricsLoaderFactory>();
            filters = new Dictionary<string, Filter>();
            validators = new Dictionary<string, Validator>();

            loadFilters();
            loadValidators();
        }