コード例 #1
0
 public string ConvertToVideoLink(string publicLink, SharedVideoResolution videoResolution)
 {
     return(GetShardInfo(ShardType.WeblinkVideo).Result.Url +
            videoResolution.ToEnumMemberValue() + "/" + //"0p/" +
            Common.Base64Encode(publicLink.TrimStart('/')) +
            ".m3u8?double_encode=1");
 }
コード例 #2
0
        public string ConvertToVideoLink(Uri publicLink, SharedVideoResolution videoResolution)
        {
            string linkstring = publicLink.PathAndQuery;

            return(GetShardInfo(ShardType.WeblinkVideo).Result.Url +
                   videoResolution.ToEnumMemberValue() + "/" +
                   Common.Base64Encode(linkstring.TrimStart('/')) +
                   ".m3u8?double_encode=1");
        }
コード例 #3
0
        public override async Task <SpecialCommandResult> Execute()
        {
            string path;
            string param = Parames.Count == 0
                ? string.Empty
                : Parames[0].Replace("\\", WebDavPath.Separator);
            SharedVideoResolution videoResolution = Parames.Count < 2
                ? Cloud.Settings.DefaultSharedVideoResolution
                : EnumExtensions.ParseEnumMemberValue <SharedVideoResolution>(Parames[1]);

            if (Parames.Count == 0)
            {
                path = Path;
            }
            else if (param.StartsWith(WebDavPath.Separator))
            {
                path = param;
            }
            else
            {
                path = WebDavPath.Combine(Path, param);
            }

            var entry = await Cloud.GetItemAsync(path);

            if (null == entry)
            {
                return(SpecialCommandResult.Fail);
            }

            try
            {
                await Cloud.Publish(entry, true, _generateDirectVideoLink, _makeM3UFile, videoResolution);
            }
            catch (Exception e)
            {
                return(new SpecialCommandResult(false, e.Message));
            }

            return(SpecialCommandResult.Success);
        }
コード例 #4
0
 public string ConvertToVideoLink(Uri publicLink, SharedVideoResolution videoResolution)
 {
     throw new NotImplementedException("Yad not implemented ConvertToVideoLink");
 }
コード例 #5
0
        public async Task <PublishInfo> Publish(IEntry entry, bool makeShareFile = true,
                                                bool generateDirectVideoLink     = false, bool makeM3UFile = false, SharedVideoResolution videoResolution = SharedVideoResolution.All)
        {
            if (null == entry)
            {
                throw new ArgumentNullException(nameof(entry));
            }

            if (entry is File file)
            {
                return(await Publish(file, makeShareFile, generateDirectVideoLink, makeM3UFile, videoResolution));
            }
            if (entry is Folder folder)
            {
                return(await Publish(folder, makeShareFile));
            }

            throw new Exception($"Unknow entry type, type = {entry.GetType()},path = {entry.FullPath}");
        }
コード例 #6
0
        public async Task <PublishInfo> Publish(File file, bool makeShareFile = true,
                                                bool generateDirectVideoLink  = false, bool makeM3UFile = false, SharedVideoResolution videoResolution = SharedVideoResolution.All)
        {
            if (file.Files.Count > 1 && (generateDirectVideoLink || makeM3UFile))
            {
                throw new ArgumentException($"Cannot generate direct video link for splitted file {file.FullPath}");
            }

            foreach (var innerFile in file.Files)
            {
                var url = await Publish(innerFile.FullPath);

                innerFile.PublicLinks.Clear();
                innerFile.PublicLinks.Add(new PublicLinkInfo(url));
            }
            var info = file.ToPublishInfo(this, generateDirectVideoLink, videoResolution);

            if (makeShareFile)
            {
                string path = $"{file.FullPath}{PublishInfo.SharedFilePostfix}";
                UploadFileJson(path, info)
                .ThrowIf(r => !r, r => new Exception($"Cannot upload JSON file, path = {path}"));
            }


            if (makeM3UFile)
            {
                string path    = $"{file.FullPath}{PublishInfo.PlaylistFilePostfix}";
                var    content = new StringBuilder();
                {
                    content.Append("#EXTM3U\r\n");
                    foreach (var item in info.Items)
                    {
                        content.Append($"#EXTINF:-1,{WebDavPath.Name(item.Path)}\r\n");
                        content.Append($"{item.PlaylistUrl}\r\n");
                    }
                }
                UploadFile(path, content.ToString())
                .ThrowIf(r => !r, r => new Exception($"Cannot upload JSON file, path = {path}"));
            }

            return(info);
        }