Exemple #1
0
        public override IEnumerable <IDestination> DynamicDestinations()
        {
            List <string> albums = null;

            try {
                albums = PhotobucketUtils.RetrievePhotobucketAlbums();
            } catch {
            }

            if (albums == null || albums.Count == 0)
            {
                yield break;
            }
            foreach (string album in albums)
            {
                yield return(new PhotobucketDestination(plugin, album));
            }
        }
Exemple #2
0
        /// <summary>
        /// Upload the capture to Photobucket
        /// </summary>
        /// <param name="captureDetails"></param>
        /// <param name="surfaceToUpload">ISurface</param>
        /// <param name="uploadURL">out string for the url</param>
        /// <returns>true if the upload succeeded</returns>
        public bool Upload(ICaptureDetails captureDetails, ISurface surfaceToUpload, string albumPath, out string uploadURL)
        {
            SurfaceOutputSettings outputSettings = new SurfaceOutputSettings(config.OutputFileFormat, config.OutputFileJpegQuality, config.OutputFileAutoReduceColors);

            try {
                string          filename        = Path.GetFileName(FilenameHelper.GetFilename(config.OutputFileFormat, captureDetails));
                PhotobucketInfo photobucketInfo = null;

                // Run upload in the background
                new PleaseWaitForm().ShowAndWait("Photobucket plug-in", Language.GetString("photobucket", LangKey.communication_wait),
                                                 delegate() {
                    photobucketInfo = PhotobucketUtils.UploadToPhotobucket(surfaceToUpload, outputSettings, albumPath, captureDetails.Title, filename);
                }
                                                 );
                // This causes an exeption if the upload failed :)
                LOG.DebugFormat("Uploaded to Photobucket page: " + photobucketInfo.Page);
                uploadURL = null;
                try {
                    if (config.UsePageLink)
                    {
                        uploadURL = photobucketInfo.Page;
                        Clipboard.SetText(photobucketInfo.Page);
                    }
                    else
                    {
                        uploadURL = photobucketInfo.Original;
                        Clipboard.SetText(photobucketInfo.Original);
                    }
                } catch (Exception ex) {
                    LOG.Error("Can't write to clipboard: ", ex);
                }
                return(true);
            } catch (Exception e) {
                LOG.Error(e);
                MessageBox.Show(Language.GetString("photobucket", LangKey.upload_failure) + " " + e.Message);
            }
            uploadURL = null;
            return(false);
        }