Ejemplo n.º 1
0
    static public void Run(IScripting scripting, string arguments)
    {
        scripting.GetConsole().Clear();
        ISelection  selection = scripting.GetSelection();
        List <long> selected  = selection.GetSelectedVideos();

        foreach (long video in selected)
        {
            // Get the video file entry
            var entry = scripting.GetVideoCatalogService().GetVideoFileEntry(video);
            scripting.GetConsole().WriteLine(System.Convert.ToString("Processing..." + entry.FilePath));

            // Get the date of the file
            DateTime creation         = File.GetCreationTime(entry.FilePath);
            String   creeation_string = creation.ToString("yyyyMMdd_HHmmss");

            // Copy the video file type extension
            var extension_start = entry.FilePath.LastIndexOf(".");
            creeation_string += entry.FilePath.Substring(extension_start);

            // and create the path to the file.
            var    path_end    = entry.FilePath.LastIndexOf("\\");
            String target_path = entry.FilePath.Substring(0, path_end);
            scripting.GetConsole().WriteLine(System.Convert.ToString("Newname to:" + target_path + "\\" + creeation_string));

            // rename the file
            System.IO.File.Move(entry.FilePath, target_path + "\\" + creeation_string);

            // and update the catalog witb the new file path
            scripting.GetVideoCatalogService().SetVideoProperty(video, "FilePath", target_path + "\\" + creeation_string);
        }

        // refresh the gui to show the changed file paths.
        scripting.GetGUI().Refresh("");
    }
Ejemplo n.º 2
0
    /// <summary>
    ///  Class constructor, extract the selected data from the interface and store in class members.
    /// </summary>
    ConvertVideo(IScripting scripting)
    {
        m_scripting = scripting;

        ISelection  selection = m_scripting.GetSelection();
        var         catalog   = m_scripting.GetVideoCatalogService();
        List <long> selected  = selection.GetSelectedVideos();

        if (selected.Count == 1)
        {
            long video = selected[0];
            var  entry = catalog.GetVideoFileEntry(video);

            IUtilities utilities = m_scripting.GetUtilities();
            m_SelectedVideoPath  = utilities.ConvertToLocalPath(entry.FilePath);
            m_SelectedVideoTitle = entry.Title;


            byte[] image_data = catalog.GetVideoFileImage(video);
            if (image_data == null)
            {
                return;
            }

            MemoryStream stream = new MemoryStream(image_data);
            m_VideoImage = System.Drawing.Bitmap.FromStream(stream);
        }
    }
Ejemplo n.º 3
0
    /// <summary>
    ///  the tool to execute is passed as argument.
    /// </summary>
    static public async System.Threading.Tasks.Task Run(IScripting scripting, string argument)
    {
        ISelection  selection = scripting.GetSelection();
        var         catalog   = scripting.GetVideoCatalogService();
        List <long> selected  = selection.GetSelectedVideos();

        if (selected.Count == 0)
        {
            System.Windows.MessageBox.Show("No Video selected", "Execute sample");
            return;
        }

        foreach (long video in selected)
        {
            var entry = catalog.GetVideoFileEntry(video);

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName    = "cmd.exe";
            string cmd_line = " copy \"" + entry.FilePath + "\" \"" + entry.FilePath + "_bak\"";
            startInfo.Arguments = "/C " + cmd_line;
            process.StartInfo   = startInfo;

            process.Start();
            process.WaitForExit();
        }
    }
Ejemplo n.º 4
0
        public static void InitAll()
        {
            Type[] types = Assembly.GetExecutingAssembly().GetTypes();
            allCmds.Clear();
            coreCmds.Clear();
            foreach (Group grp in Group.GroupList)
            {
                grp.Commands.Clear();
            }

            for (int i = 0; i < types.Length; i++)
            {
                Type type = types[i];
                if (!type.IsSubclassOf(typeof(Command)) || type.IsAbstract)
                {
                    continue;
                }

                Command cmd = (Command)Activator.CreateInstance(type);
                Register(cmd);
            }

            coreCmds = new List <Command>(allCmds);
            IScripting.Autoload();
        }
Ejemplo n.º 5
0
        public static void InitAll()
        {
            all.commands.Clear();
            core.commands.Clear();
            all.AddOtherPerms = true;
            Type[] types = Assembly.GetExecutingAssembly().GetTypes();

            for (int i = 0; i < types.Length; i++)
            {
                Type type = types[i];
                if (!type.IsSubclassOf(typeof(Command)) || type.IsAbstract)
                {
                    continue;
                }
                Command cmd = (Command)Activator.CreateInstance(type);
                all.Add(cmd);

                CommandAlias[] aliases = cmd.Aliases;
                if (aliases == null)
                {
                    continue;
                }
                foreach (CommandAlias a in aliases)
                {
                    Alias alias = new Alias(a.Trigger, cmd.name, a.Prefix, a.Suffix);
                    Alias.coreAliases.Add(alias);
                }
            }
            core.commands = new List <Command>(all.commands);
            IScripting.Autoload();
        }
Ejemplo n.º 6
0
 public static void LoadAll()
 {
     LoadCorePlugin(new CorePlugin());
     LoadCorePlugin(new NotesPlugin());
     LoadCorePlugin(new DiscordPlugin());
     IScripting.AutoloadPlugins();
 }
Ejemplo n.º 7
0
        void btnCreate_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtCmdName.Text.Trim()))
            {
                MessageBox.Show("Command must have a name");
                return;
            }

            string     cmdName = txtCmdName.Text.Trim().ToLower();
            IScripting engine  = radVB.Checked ? IScripting.VB : IScripting.CS;

            if (engine.SourceFileExists(cmdName))
            {
                MessageBox.Show("Command already exists", "", MessageBoxButtons.OK);
                return;
            }

            try {
                engine.CreateNew(cmdName);
            } catch (Exception ex) {
                Logger.LogError(ex);
                MessageBox.Show("An error occurred creating the class file.", "", MessageBoxButtons.OK);
                return;
            }
            MessageBox.Show("Command: Cmd" + cmdName + engine.Ext + " created.");
        }
Ejemplo n.º 8
0
        void btnLoad_Click(object sender, EventArgs e)
        {
            Assembly lib;
            string   path;

            using (FileDialog dialog = new OpenFileDialog()) {
                dialog.RestoreDirectory = true;
                dialog.Filter           = GetFilterText();

                if (dialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                path = dialog.FileName;
            }
            if (!File.Exists(path))
            {
                return;
            }

            if (path.CaselessEnds(".dll"))
            {
                lib = IScripting.LoadAssembly(path);
            }
            else
            {
                lib = CompileCommands(path);
            }

            if (lib == null)
            {
                return;
            }
            LoadCommands(lib);
        }
Ejemplo n.º 9
0
    /// <summary>
    ///  This is the entry function called by fvc.
    /// </summary>
    static public async System.Threading.Tasks.Task Run(IScripting scripting, string argument)
    {
        scripting.GetConsole().Clear();
        ISelection selection = scripting.GetSelection();
        var        playlist  = selection.GetSelectedPlaylist();

        if (playlist == null)
        {
            scripting.GetConsole().WriteLine("Select a playlist");
            return;
        }

        if (ConcatPlaylist.GetFFMPEGPath() == null)
        {
            return;
        }

        if (ConcatPlaylist.GetTempFolder() == null)
        {
            return;
        }

        ConcatPlaylist merger = new ConcatPlaylist(scripting);

        merger.Concat(null, null);
    }
Ejemplo n.º 10
0
        void btnCreate_Click(object sender, EventArgs e)
        {
            string cmdName = txtCmdName.Text.Trim();

            if (cmdName.Length == 0)
            {
                Popup.Warning("Command must have a name"); return;
            }

            IScripting engine = radVB.Checked ? IScripting.VB : IScripting.CS;
            string     path   = engine.SourcePath(cmdName);

            if (File.Exists(path))
            {
                Popup.Warning("Command already exists"); return;
            }

            try {
                engine.CreateNew(path, cmdName);
            } catch (Exception ex) {
                Logger.LogError(ex);
                Popup.Error("Failed to generate command. Check error logs for more details.");
                return;
            }
            Popup.Message("Command Cmd" + cmdName + engine.Ext + " created.");
        }
Ejemplo n.º 11
0
        public override void Use(Player p, string message, CommandData data)
        {
            if (message.Length == 0)
            {
                Help(p); return;
            }
            string[] args = message.SplitSpaces();
            if (!Formatter.CheckFilenameOnly(p, args[0]))
            {
                return;
            }

            string    language = args.Length > 1 ? args[1] : "";
            ICompiler compiler = ICompiler.Lookup(language, p);

            if (compiler == null)
            {
                return;
            }

            // either "source" or "source1,source2,source3"
            string[] paths   = args[0].SplitComma();
            string   dstPath = IScripting.CommandPath(paths[0]);

            for (int i = 0; i < paths.Length; i++)
            {
                paths[i] = compiler.CommandPath(paths[i]);
            }
            compiler.Compile(p, "Command", paths, dstPath);
        }
Ejemplo n.º 12
0
        static void CompilePlugin(Player p, string name, string language)
        {
            ICompiler engine = ICompiler.Lookup(language, p);

            if (engine == null)
            {
                return;
            }

            string srcPath = "plugins/" + name + engine.Ext;
            string dstPath = IScripting.PluginPath(name);

            if (!File.Exists(srcPath))
            {
                p.Message("File &9{0} &Snot found.", srcPath); return;
            }

            CompilerResults results = engine.Compile(srcPath, dstPath);

            if (!results.Errors.HasErrors)
            {
                p.Message("Plugin compiled successfully.");
            }
            else
            {
                ICompiler.SummariseErrors(results, p);
                p.Message("&WCompilation error. See " + ICompiler.ErrorPath + " for more information.");
            }
        }
Ejemplo n.º 13
0
        public override void Use(Player p, string cmdName, CommandData data)
        {
            if (!Formatter.ValidName(p, cmdName, "command"))
            {
                return;
            }
            if (Command.Find(cmdName) != null)
            {
                p.Message("That command is already loaded!"); return;
            }

            string path = IScripting.DllPath(cmdName);

            if (!File.Exists(path))
            {
                p.Message("File &9{0} &Snot found.", path); return;
            }

            string error = IScripting.Load(path);

            if (error != null)
            {
                p.Message("&W" + error); return;
            }
            p.Message("Command was successfully loaded.");
        }
Ejemplo n.º 14
0
        internal static string DropForeignKey(string integrityDropString)
        {
            IScripting scriptor = Scripting.CreateClass();

            string[] keySplit = integrityDropString.Split(new string[] { "||" }, StringSplitOptions.RemoveEmptyEntries);

            return(scripting.DropForeignKey(keySplit[0], keySplit[1]));
        }
Ejemplo n.º 15
0
    /// <summary>
    ///  Run sample. This is the entry function called by fvc.
    /// </summary>
    static public void Run(IScripting scripting, string argument)
    {
        FilterToBin instance = new FilterToBin(scripting);

        instance.SetBinTarget("short videos");
        instance.Filter();
        scripting.GetGUI().Refresh("");
    }
Ejemplo n.º 16
0
    static public async System.Threading.Tasks.Task Run(IScripting scripting, string argument)
    {
        FilterToBin instance = new FilterToBin(scripting);

        instance.SetBinTarget("short videos");
        instance.Filter();
        scripting.GetGUI().Refresh("");
    }
Ejemplo n.º 17
0
        /// <summary>
        /// </summary>
        static public void Run(IScripting scripting, string argument)
        {
            ISelection  selection = scripting.GetSelection();
            List <long> selected  = selection.GetSelectedVideos();

            if (selected == null)
            {
                scripting.GetConsole().WriteLine("Please select videos to add keywords to");
                return;
            }

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.FileName   = "csvfile";                                  // Default file name
            dlg.DefaultExt = ".csv";                                     // Default file extension
            dlg.Filter     = "csv file (.csv)|*.csv|All files (.*)|*.*"; // Filter files by extension
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                var catalog = scripting.GetVideoCatalogService();

                string csv_path  = dlg.FileName;
                char[] separator = { ',', ';', '.' };

                try
                {
                    using (var textReader = new StreamReader(csv_path))
                    {
                        scripting.GetConsole().WriteLine("Reading from " + csv_path);
                        string line = textReader.ReadLine();
                        while (line != null)
                        {
                            string[] columns = line.Split(separator);

                            //perform your logic
                            foreach (string new_tag_string in columns)
                            {
                                foreach (long video_id in selected)
                                {
                                    catalog.TagVideo(video_id, new_tag_string);
                                    scripting.GetConsole().WriteLine("Adding keyword " + new_tag_string + " to video " + video_id);
                                }
                            }

                            line = textReader.ReadLine();
                        }

                        scripting.GetConsole().WriteLine("Import done");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Ejemplo n.º 18
0
    /// <summary>
    ///  Run sample. This is the entry function called by fvc.
    /// </summary>
    static public async System.Threading.Tasks.Task Run(IScripting scripting, string argument)
    {
        scripting.GetConsole().Clear();
        ISelection  selection = scripting.GetSelection();
        List <long> selected  = selection.GetSelectedVideos();

        foreach (long video in selected)
        {
            scripting.GetConsole().WriteLine(System.Convert.ToString(video));
        }
    }
Ejemplo n.º 19
0
        static void CompilePlugin(Player p, string name, ICompiler compiler)
        {
            // either "source" or "source1,source2,source3"
            string[] paths   = name.SplitComma();
            string   dstPath = IScripting.PluginPath(paths[0]);

            for (int i = 0; i < paths.Length; i++)
            {
                paths[i] = compiler.PluginPath(paths[i]);
            }
            CompilerOperations.Compile(p, compiler, "Plugin", paths, dstPath);
        }
Ejemplo n.º 20
0
 static void LoadPlugin(Player p, string name) {
     string path = IScripting.PluginPath(name);
     if (File.Exists(path)) {
         if (Plugin.Load(name, false)) {
             p.Message("Plugin loaded successfully.");
         } else {
             p.Message("%WError loading plugin. See error logs for more information.");
         }
     } else {
         p.Message("File &9{0} %Snot found.", path);
     }
 }
Ejemplo n.º 21
0
    /// <summary>
    ///  Run sample. This is the entry function called by fvc.
    /// </summary>
    static public void Run(IScripting scripting, string argument)
    {
        ISelection  selection = scripting.GetSelection();
        var         catalog   = scripting.GetVideoCatalogService();
        List <long> selected  = selection.GetSelectedVideos();

        foreach (long video in selected)
        {
            // set the Rating property to 1 for each of the selected videos
            scripting.GetVideoCatalogService().SetVideoProperty(video, "Rating", "1");
        }
    }
Ejemplo n.º 22
0
    /// <summary>
    ///  Run sample. This is the entry function called by fvc.
    /// </summary>
    static public async System.Threading.Tasks.Task Run(IScripting scripting, string argument)
    {
        ISelection  selection = scripting.GetSelection();
        var         catalog   = scripting.GetVideoCatalogService();
        List <long> selected  = selection.GetSelectedVideos();

        if (selected.Count > 0)
        {
            byte[] image = catalog.GetVideoFileImage(selected[0]);
            ShowImagePopup(image);
        }
    }
Ejemplo n.º 23
0
    /// <summary>
    ///  Run sample. This is the entry function called by fvc.
    /// </summary>
    static public void Run(IScripting scripting, string argument)
    {
        ISelection  selection = scripting.GetSelection();
        var         catalog   = scripting.GetVideoCatalogService();
        List <long> selected  = selection.GetSelectedVideos();

        foreach (long video in selected)
        {
            var entry = catalog.GetVideoFileEntry(selected[0]);
            System.Windows.MessageBox.Show(entry.FilePath, "Selected Video");
        }
    }
Ejemplo n.º 24
0
    /// <summary>
    ///  Run sample. This is the entry function called by fvc.
    /// </summary>
    static public async System.Threading.Tasks.Task Run(IScripting scripting, string argument)
    {
        scripting.GetConsole().Clear();
        ISelection selection = scripting.GetSelection();
        var        catalog   = scripting.GetVideoCatalogService();

        long   summary_playlist = -1;
        string playlist_name    = "Sumary";
        var    all_playlists    = catalog.GetAllVideoPlaylists( );

        if (all_playlists != null)
        {
            foreach (var playlist in all_playlists)
            {
                if (playlist.Name == playlist_name)
                {
                    int[] playlist_clips = catalog.GetPlaylistClipIDs(playlist.ID);
                    foreach (int video_clip in playlist_clips)
                    {
                        catalog.RemovePlaylistClip(playlist.ID, video_clip);
                        catalog.DeleteVideoClip(video_clip);
                    }
                    summary_playlist = playlist.ID;
                }
            }
        }

        if (summary_playlist == -1)
        {
            summary_playlist = catalog.CreateVideoPlaylist(playlist_name);
        }

        VideoCataloger.RemoteCatalogService.VideoClip clip = new VideoCataloger.RemoteCatalogService.VideoClip();
        clip.ID        = -1; // -1 to create new clip
        clip.StartTime = 20;
        clip.EndTime   = 25;
        int         playlist_position = 0;
        List <long> selected          = selection.GetSelectedVideos();

        if (selected != null)
        {
            foreach (long video in selected)
            {
                clip.VideoFileID = video;
                int new_clip_id = catalog.SetVideoClip(clip);
                catalog.SetClipToPlaylist(summary_playlist, playlist_position++, new_clip_id);
            }
        }
        scripting.GetGUI().Refresh("");
    }
Ejemplo n.º 25
0
        static public void Run(IScripting scripting, string argument)
        {
            m_scripting = scripting;

            if (api_key == "")
            {
                m_scripting.GetConsole().WriteLine("Replace api_key with your personal api key from https://www.themoviedb.org/");
                return;
            }

            GetActors wnd = new GetActors();

            wnd.Show();
        }
Ejemplo n.º 26
0
 static void CompilePlugin(Player p, string name) {
     IScripting engine = IScripting.CS;
     string srcPath = "plugins/" + name + engine.Ext;
     string dstPath = IScripting.PluginPath(name);
     
     if (File.Exists(srcPath)) {
         if (engine.Compile(srcPath, dstPath)) {
             p.Message("Plugin compiled successfully.");
         } else {
             p.Message("Compilation error. See " + IScripting.ErrorPath + " for more information.");
         }
     } else {
         p.Message("File &9{0} %Snot found.", srcPath);
     }
 }
Ejemplo n.º 27
0
    /// <summary>
    ///  This is the entry function called by fvc.
    /// </summary>
    static public void Run(IScripting scripting, string argument)
    {
        scripting.GetConsole().Clear();
        ISelection  selection = scripting.GetSelection();
        List <long> selected  = selection.GetSelectedVideos();

        if (selected.Count == 1)
        {
            scripting.GetConsole().WriteLine("Select more than one video");
            return;
        }

        ConcatVideos merger = new ConcatVideos(scripting);

        merger.Concat(null, null);
    }
Ejemplo n.º 28
0
        private static IScripting CreateClass()
        {
            if (Scripting.scripting != null && Scripting.scripting.DatabaseScriptingType == Connections.DatabaseModel.DatabaseType)
            {
                return(Scripting.scripting);
            }

            switch (Connections.DatabaseModel.DatabaseType)
            {
            case DatabaseTypeEnum.SQL:
            default:
                Scripting.scripting = new MsScripting();

                break;
            }

            return(Scripting.scripting);
        }
Ejemplo n.º 29
0
        static void CompilePlugin(Player p, string name, string language)
        {
            ICompiler compiler = ICompiler.Lookup(language, p);

            if (compiler == null)
            {
                return;
            }

            // either "source" or "source1,source2,source3"
            string[] paths   = name.SplitComma();
            string   dstPath = IScripting.PluginPath(paths[0]);

            for (int i = 0; i < paths.Length; i++)
            {
                paths[i] = compiler.PluginPath(paths[i]);
            }
            ScriptingOperations.Compile(p, compiler, "Plugin", paths, dstPath);
        }
Ejemplo n.º 30
0
        void LoadCommands(Assembly assembly)
        {
            List <Command> commands = IScripting.LoadTypes <Command>(assembly);

            for (int i = 0; i < commands.Count; i++)
            {
                Command cmd = commands[i];

                if (lstCommands.Items.Contains(cmd.name))
                {
                    Popup.Warning("Command " + cmd.name + " already exists, so was not loaded");
                    continue;
                }

                lstCommands.Items.Add(cmd.name);
                Command.Register(cmd);
                Logger.Log(LogType.SystemActivity, "Added " + cmd.name + " to commands");
            }
        }