Beispiel #1
0
        public static int Main(string[] args)
        {
            LoggerFactory.AddFile("Logs/myapp-{Date}.log");
            LoggerFactory.AddConsole();

            ILogger Logger = LoggerFactory.CreateLogger <Program>();

            Logger.LogInformation("Starting Image Extractor");

            FileInfo fi = new FileInfo("/Users/TomHalter/Documents/catalog.pse14db");

            if (!fi.Exists)
            {
                Logger.LogCritical("File not found");
                return(1);
            }

            PseContext db = new PseContext($"Filename={fi.FullName}");

            MediaExporter exporter = new MediaExporter
            {
                Context  = db,
                Simulate = true
            };

            MediaExportResult mer = exporter.Export();

            return(0);
        }
    void ExportFirstSong()
    {
        MPMediaQuery query = MPMediaQuery.SongsQuery();

        if (query.items.Length == 0)
        {
            Log("No songs in Music Library.");
            return;
        }

        // get first song
        MPMediaItem mediaItem = query.items[0] as MPMediaItem;

        Log("Exporting song: " + mediaItem.Value(MPMediaItem.PropertyTitle));

        // use null for outputFolder and outputFile to name it [artist] - [title]
        if (!MediaExporter.ExportAudio(mediaItem, null, null, true))
        {
            Log("Export error or song has DRM.");
        }
    }