Exemple #1
0
        public UploadResult ShortenURL(string url)
        {
            URLShortener urlShortener = null;

            switch (Info.TaskSettings.URLShortenerDestination)
            {
            case UrlShortenerType.BITLY:
                if (Program.UploadersConfig.BitlyOAuth2Info == null)
                {
                    Program.UploadersConfig.BitlyOAuth2Info = new OAuth2Info(APIKeys.BitlyClientID, APIKeys.BitlyClientSecret);
                }

                urlShortener = new BitlyURLShortener(Program.UploadersConfig.BitlyOAuth2Info);
                break;

            case UrlShortenerType.Google:
                urlShortener = new GoogleURLShortener(Program.UploadersConfig.GoogleURLShortenerAccountType, APIKeys.GoogleAPIKey,
                                                      Program.UploadersConfig.GoogleURLShortenerOAuth2Info);
                break;

            case UrlShortenerType.ISGD:
                urlShortener = new IsgdURLShortener();
                break;

            /*case UrlShortenerType.THREELY:
             * urlShortener = new ThreelyURLShortener(Program.ThreelyKey);
             * break;*/
            case UrlShortenerType.TINYURL:
                urlShortener = new TinyURLShortener();
                break;

            case UrlShortenerType.TURL:
                urlShortener = new TurlURLShortener();
                break;

            case UrlShortenerType.YOURLS:
                urlShortener = new YourlsURLShortener
                {
                    APIURL    = Program.UploadersConfig.YourlsAPIURL,
                    Signature = Program.UploadersConfig.YourlsSignature,
                    Username  = Program.UploadersConfig.YourlsUsername,
                    Password  = Program.UploadersConfig.YourlsPassword
                };
                break;

            case UrlShortenerType.CustomURLShortener:
                if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomURLShortenerSelected))
                {
                    urlShortener = new CustomURLShortener(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomURLShortenerSelected]);
                }
                break;
            }

            if (urlShortener != null)
            {
                return(urlShortener.ShortenURL(url));
            }

            return(null);
        }
        public UploadResult ShortenURL(string url)
        {
            URLShortener urlShortener = null;

            switch (Info.TaskSettings.URLShortenerDestination)
            {
            case UrlShortenerType.BITLY:
                urlShortener = new BitlyURLShortener(ApiKeys.BitlyLogin, ApiKeys.BitlyKey);
                break;

            case UrlShortenerType.Google:
                urlShortener = new GoogleURLShortener(Program.UploadersConfig.GoogleURLShortenerAccountType, ApiKeys.GoogleAPIKey,
                                                      Program.UploadersConfig.GoogleURLShortenerOAuth2Info);
                break;

            case UrlShortenerType.ISGD:
                urlShortener = new IsgdURLShortener();
                break;

            case UrlShortenerType.Jmp:
                urlShortener = new JmpURLShortener(ApiKeys.BitlyLogin, ApiKeys.BitlyKey);
                break;

            /*case UrlShortenerType.THREELY:
             * urlShortener = new ThreelyURLShortener(Program.ThreelyKey);
             * break;*/
            case UrlShortenerType.TINYURL:
                urlShortener = new TinyURLShortener();
                break;

            case UrlShortenerType.TURL:
                urlShortener = new TurlURLShortener();
                break;

            case UrlShortenerType.CustomURLShortener:
                if (Program.UploadersConfig.CustomUploadersList.IsValidIndex(Program.UploadersConfig.CustomURLShortenerSelected))
                {
                    urlShortener = new CustomURLShortener(Program.UploadersConfig.CustomUploadersList[Program.UploadersConfig.CustomURLShortenerSelected]);
                }
                break;
            }

            if (urlShortener != null)
            {
                return(urlShortener.ShortenURL(url));
            }

            return(null);
        }
        public string ShortenURL(string url)
        {
            URLShortener urlShortener = null;

            switch (UploadManager.URLShortener)
            {
            case UrlShortenerType.BITLY:
                urlShortener = new BitlyURLShortener(ZKeys.BitlyLogin, ZKeys.BitlyKey);
                break;

            case UrlShortenerType.Google:
                urlShortener = new GoogleURLShortener(Program.UploadersConfig.GoogleURLShortenerAccountType, ZKeys.GoogleApiKey,
                                                      Program.UploadersConfig.GoogleURLShortenerOAuthInfo);
                break;

            case UrlShortenerType.ISGD:
                urlShortener = new IsgdURLShortener();
                break;

            case UrlShortenerType.Jmp:
                urlShortener = new JmpURLShortener(ZKeys.BitlyLogin, ZKeys.BitlyKey);
                break;

            /*case UrlShortenerType.THREELY:
             *  urlShortener = new ThreelyURLShortener(Program.ThreelyKey);
             *  break;*/
            case UrlShortenerType.TINYURL:
                urlShortener = new TinyURLShortener();
                break;

            case UrlShortenerType.TURL:
                urlShortener = new TurlURLShortener();
                break;
            }

            if (urlShortener != null)
            {
                Status = TaskStatus.URLShortening;
                return(urlShortener.ShortenURL(url));
            }

            return(null);
        }