示例#1
0
        public RecordsList(string endpoint)
        {
            Data = new JObject();
            List = new List <Record> ();

            RecordClient   = Client.GetClient();
            RecordEndpoint = endpoint;
        }
示例#2
0
        public Record(string endpoint)
        {
            Data       = JObject.Parse(empty_record);
            Parameters = new Dictionary <string, object> ();
            cache      = new JObject();

            RecordClient   = Client.GetClient();
            RecordEndpoint = endpoint;
        }
示例#3
0
        public static string  UsingVideoCreateFromFile(string id, string token, string filepath)
        {
            try {
                Console.WriteLine("--Create(filepath)--");

                Client client = Client.GetClient();
                client.UploadProgress += myDelegateUser.CheckProgress;
                var task = Video.CreateAsync(filepath, client);
                task.Wait();

                var video = task.Result;

                Console.WriteLine("Id: " + video["id"] + " Title: " + video["title"]);


                return("Id: " + video["id"].ToString());
//				Console.WriteLine ("--Delete--");
//
//				var videoId = (long)video ["id"];
//				video.Delete ();
//
//				Console.WriteLine ("--Find after delete--");
//				video = Video.Find (videoId);
            } catch (VzaarApiException ve) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(ve.Message);
                return(ve.Message);
            } catch (Exception e) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(e.Message);

                if (e is AggregateException)
                {
                    AggregateException ae = (AggregateException)e;

                    var flatten = ae.Flatten();

                    foreach (var fe in flatten.InnerExceptions)
                    {
                        if (fe is VzaarApiException)
                        {
                            Console.WriteLine(fe.Message);
                        }
                        return(fe.Message);
                    }
                }
                return(e.Message);
            }
        }
示例#4
0
        public static void UsingPlaylist(string id, string token, int category_id)
        {
            try {
                Console.WriteLine("--Create(tokens)--");

                Dictionary <string, object> tokens = new Dictionary <string, object> ()
                {
                    { "title", "Example Playlist" },
                    { "category_id", category_id }
                };

                var itemNew = Playlist.Create(tokens);
                Console.WriteLine("Id: " + itemNew["id"] + " Title: " + itemNew["title"]);

                //lookup
                Console.WriteLine("--Find(id)--");

                var item = Playlist.Find((long)itemNew["id"]);

                Console.WriteLine("--Access with property name--");
                Console.WriteLine("Id: " + item["id"] + " Title: " + item["title"]);

                Console.WriteLine("--Access with the record Type--");

                Client client = Client.GetClient();

                var item2 = Playlist.Find((long)item["id"], client);

                var record1 = (PlaylistType)item2.ToTypeDef(typeof(PlaylistType));
                Console.WriteLine("Id: " + record1.id + " Title: " + record1.title + " Created: " + record1.created_at);

                Console.WriteLine("--Access with custom Type--");

                var record2 = (myType)item2.ToTypeDef(typeof(myType));
                Console.WriteLine("Id: " + record2.id + " Title: " + record2.title);

                //update
                Console.WriteLine("--Update1--");

                Console.WriteLine("--Before: Save(tokens)--");
                Console.WriteLine("Id: " + item2["id"] + " Autoplay: " + item2["autoplay"].ToString());

                Dictionary <string, object> tokens2 = new Dictionary <string, object> ()
                {
                    { "autoplay", true }
                };

                item2.Save(tokens2);

                Console.WriteLine("--After: Save(tokens)--");
                Console.WriteLine("Id: " + item2["id"] + " Autoplay: " + item2["autoplay"].ToString());


                Console.WriteLine("--Delete--");

                var deleteId = (long)item2 ["id"];
                item2.Delete();

                Console.WriteLine("--Find after delete--");
                item2 = Playlist.Find(deleteId);
            } catch (VzaarApiException ve) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(ve.Message);
            } catch (Exception e) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(e.Message);

                if (e is AggregateException)
                {
                    AggregateException ae = (AggregateException)e;

                    var flatten = ae.Flatten();

                    foreach (var fe in flatten.InnerExceptions)
                    {
                        if (fe is VzaarApiException)
                        {
                            Console.WriteLine(fe.Message);
                        }
                    }
                }
            }
        }
        public static void UsingIngestRecipe(string id, string token)
        {
            try {
                Console.WriteLine("--Create(tokens)--");

                long[] presetIds = { 3, 10 };

                Dictionary <string, object> tokens = new Dictionary <string, object> ()
                {
                    { "name", "Example Recipe" },
                    { "encoding_preset_ids", presetIds },
                    { "multipass", false }
                };

                var itemNew = Recipe.Create(tokens);
                Console.WriteLine("Id: " + itemNew["id"] + " Name: " + itemNew["name"]);

                //lookup
                Console.WriteLine("--Find(id)--");

                var item = Recipe.Find((long)itemNew["id"]);

                Console.WriteLine("--Access with property name--");
                Console.WriteLine("Id: " + item["id"] + " Name: " + item["name"]);

                Console.WriteLine("--Access with the record Type--");

                Client client = Client.GetClient();

                var item2 = Recipe.Find((long)item["id"], client);

                var record1 = (IngestRecipeType)item2.ToTypeDef(typeof(IngestRecipeType));
                Console.WriteLine("Id: " + record1.id + " Name: " + record1.name + " Created: " + record1.created_at);

                Console.WriteLine("--Access with custom Type--");

                var record2 = (myType)item2.ToTypeDef(typeof(myType));
                Console.WriteLine("Id: " + record2.id + " Name: " + record2.name);

                //update
                Console.WriteLine("--Update1--");

                Console.WriteLine("--Before: Save(tokens)--");
                Console.WriteLine("Id: " + item2["id"] + " Multipass: "******"multipass"].ToString());

                Dictionary <string, object> tokens2 = new Dictionary <string, object> ()
                {
                    { "multipass", true }
                };

                item2.Save(tokens2);

                Console.WriteLine("--After: Save(tokens)--");
                Console.WriteLine("Id: " + item2["id"] + " Multipass: "******"multipass"].ToString());

                Console.WriteLine("--Update2--");

                Console.WriteLine("--Before: Save()--");
                Console.Write("Id: " + item2["id"] + "Encoding Presets: ");

                var presets = (List <Dictionary <string, object> >)item2["encoding_presets"];

                List <long> newEncoding = new List <long>();

                foreach (var p in presets)
                {
                    newEncoding.Add((long)p["id"]);

                    Console.Write(" " + p["id"]);
                }

                Console.WriteLine();

                //add new encoding to the current list
                newEncoding.Add(2);

                item2 ["encoding_preset_ids"] = newEncoding;

                item2.Save();

                Console.WriteLine("--After: Save()--");
                Console.WriteLine("Id: " + item2["id"] + "Encoding Presets: ");

                var record3 = (IngestRecipeType)item2.ToTypeDef(typeof(IngestRecipeType));

                foreach (var p in record3.encoding_presets)
                {
                    Console.Write(" " + p.id);
                }

                Console.WriteLine();


                Console.WriteLine("--Update3--");

                Console.WriteLine("--Before: Save()--");
                Console.Write("Id: " + item2["id"] + "Encoding Presets: ");

                var record = (IngestRecipeType)item2.ToTypeDef(typeof(IngestRecipeType));

                newEncoding = new List <long>();

                foreach (var p in record.encoding_presets)
                {
                    newEncoding.Add((long)p.id);

                    Console.Write(" " + p.id);
                }

                Console.WriteLine();

                //remove encoding from the current list
                newEncoding.Remove(2);

                item2 ["encoding_preset_ids"] = newEncoding;

                item2.Save();

                Console.WriteLine("--After: Save()--");
                Console.WriteLine("Id: " + item2["id"] + "Encoding Presets: ");

                record = (IngestRecipeType)item2.ToTypeDef(typeof(IngestRecipeType));

                foreach (var p in record.encoding_presets)
                {
                    Console.Write(" " + p.id);
                }

                Console.WriteLine();



                Console.WriteLine("--Delete--");

                var deleteId = (long)item2 ["id"];
                item2.Delete();

                Console.WriteLine("--Find after delete--");
                item2 = Recipe.Find(deleteId);
            } catch (VzaarApiException ve) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(ve.Message);
            } catch (Exception e) {
                Console.Write("!!!!!!!!! EXCEPTION !!!!!!!!!");
                Console.WriteLine(e.Message);

                if (e is AggregateException)
                {
                    AggregateException ae = (AggregateException)e;

                    var flatten = ae.Flatten();

                    foreach (var fe in flatten.InnerExceptions)
                    {
                        if (fe is VzaarApiException)
                        {
                            Console.WriteLine(fe.Message);
                        }
                    }
                }
            }
        }