Added direct link option to Flickr

This commit is contained in:
Jaex 2017-10-09 10:14:02 +03:00
parent c2736389c2
commit 10d7476abb
4 changed files with 60 additions and 29 deletions

View file

@ -602,6 +602,7 @@ private void InitializeComponent()
this.lblTinyPicUsername = new System.Windows.Forms.Label();
this.btnTinyPicOpenMyImages = new System.Windows.Forms.Button();
this.tpFlickr = new System.Windows.Forms.TabPage();
this.cbFlickrDirectLink = new System.Windows.Forms.CheckBox();
this.oauthFlickr = new ShareX.UploadersLib.OAuthControl();
this.tpPhotobucket = new System.Windows.Forms.TabPage();
this.gbPhotobucketAlbumPath = new System.Windows.Forms.GroupBox();
@ -4953,11 +4954,19 @@ private void InitializeComponent()
//
// tpFlickr
//
this.tpFlickr.Controls.Add(this.cbFlickrDirectLink);
this.tpFlickr.Controls.Add(this.oauthFlickr);
resources.ApplyResources(this.tpFlickr, "tpFlickr");
this.tpFlickr.Name = "tpFlickr";
this.tpFlickr.UseVisualStyleBackColor = true;
//
// cbFlickrDirectLink
//
resources.ApplyResources(this.cbFlickrDirectLink, "cbFlickrDirectLink");
this.cbFlickrDirectLink.Name = "cbFlickrDirectLink";
this.cbFlickrDirectLink.UseVisualStyleBackColor = true;
this.cbFlickrDirectLink.CheckedChanged += new System.EventHandler(this.cbFlickrDirectLink_CheckedChanged);
//
// oauthFlickr
//
this.oauthFlickr.IsRefreshable = false;
@ -5453,6 +5462,7 @@ private void InitializeComponent()
this.tpTinyPic.ResumeLayout(false);
this.tpTinyPic.PerformLayout();
this.tpFlickr.ResumeLayout(false);
this.tpFlickr.PerformLayout();
this.tpPhotobucket.ResumeLayout(false);
this.gbPhotobucketAlbumPath.ResumeLayout(false);
this.gbPhotobucketAlbumPath.PerformLayout();
@ -6092,5 +6102,6 @@ private void InitializeComponent()
private System.Windows.Forms.Button btnAmazonS3StorageClassHelp;
private System.Windows.Forms.Button btnPaste_eeGetUserKey;
private OAuthControl oauthFlickr;
private System.Windows.Forms.CheckBox cbFlickrDirectLink;
}
}

View file

@ -217,6 +217,8 @@ public void LoadSettings()
oauthFlickr.Status = OAuthLoginStatus.LoginSuccessful;
}
cbFlickrDirectLink.Checked = Config.FlickrSettings.DirectLink;
#endregion
#region Photobucket
@ -1033,6 +1035,11 @@ private void oauthFlickr_ClearButtonClicked()
Config.FlickrOAuthInfo = null;
}
private void cbFlickrDirectLink_CheckedChanged(object sender, EventArgs e)
{
Config.FlickrSettings.DirectLink = cbFlickrDirectLink.Checked;
}
#endregion Flickr
#region Photobucket

View file

@ -14849,6 +14849,33 @@ Using an encrypted library disables sharing.</value>
<data name="&gt;&gt;tpTinyPic.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="cbFlickrDirectLink.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="cbFlickrDirectLink.Location" type="System.Drawing.Point, System.Drawing">
<value>16, 224</value>
</data>
<data name="cbFlickrDirectLink.Size" type="System.Drawing.Size, System.Drawing">
<value>93, 17</value>
</data>
<data name="cbFlickrDirectLink.TabIndex" type="System.Int32, mscorlib">
<value>7</value>
</data>
<data name="cbFlickrDirectLink.Text" xml:space="preserve">
<value>Use direct link</value>
</data>
<data name="&gt;&gt;cbFlickrDirectLink.Name" xml:space="preserve">
<value>cbFlickrDirectLink</value>
</data>
<data name="&gt;&gt;cbFlickrDirectLink.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cbFlickrDirectLink.Parent" xml:space="preserve">
<value>tpFlickr</value>
</data>
<data name="&gt;&gt;cbFlickrDirectLink.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="oauthFlickr.Location" type="System.Drawing.Point, System.Drawing">
<value>16, 16</value>
</data>
@ -14868,7 +14895,7 @@ Using an encrypted library disables sharing.</value>
<value>tpFlickr</value>
</data>
<data name="&gt;&gt;oauthFlickr.ZOrder" xml:space="preserve">
<value>0</value>
<value>1</value>
</data>
<data name="tpFlickr.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 22</value>

View file

@ -129,7 +129,18 @@ public override UploadResult Upload(Stream stream, string fileName)
{
string photoid = xele.Value;
FlickrPhotosGetSizesResponse photos = PhotosGetSizes(photoid);
result.URL = photos?.sizes?.size[photos.sizes.size.Length - 1].source;
FlickrPhotosGetSizesSize photo = photos?.sizes?.size?[photos.sizes.size.Length - 1];
if (photo != null)
{
if (Settings.DirectLink)
{
result.URL = photo.source;
}
else
{
result.URL = photo.url;
}
}
}
}
@ -165,57 +176,32 @@ private XElement ParseResponse(string response, string field)
public class FlickrSettings
{
/// <summary>
/// The title of the photo.
/// </summary>
public bool DirectLink { get; set; } = true;
[Description("The title of the photo.")]
public string Title { get; set; }
/// <summary>
/// A description of the photo. May contain some limited HTML.
/// </summary>
[Description("A description of the photo. May contain some limited HTML.")]
public string Description { get; set; }
/// <summary>
/// A space-seperated list of tags to apply to the photo.
/// </summary>
[Description("A space-seperated list of tags to apply to the photo.")]
public string Tags { get; set; }
/// <summary>
/// Set to 0 for no, 1 for yes. Specifies who can view the photo.
/// </summary>
[Description("Set to 0 for no, 1 for yes. Specifies who can view the photo.")]
public string IsPublic { get; set; }
/// <summary>
/// Set to 0 for no, 1 for yes. Specifies who can view the photo.
/// </summary>
[Description("Set to 0 for no, 1 for yes. Specifies who can view the photo.")]
public string IsFriend { get; set; }
/// <summary>
/// Set to 0 for no, 1 for yes. Specifies who can view the photo.
/// </summary>
[Description("Set to 0 for no, 1 for yes. Specifies who can view the photo.")]
public string IsFamily { get; set; }
/// <summary>
/// Set to 1 for Safe, 2 for Moderate, or 3 for Restricted.
/// </summary>
[Description("Set to 1 for Safe, 2 for Moderate, or 3 for Restricted.")]
public string SafetyLevel { get; set; }
/// <summary>
/// Set to 1 for Photo, 2 for Screenshot, or 3 for Other.
/// </summary>
[Description("Set to 1 for Photo, 2 for Screenshot, or 3 for Other.")]
public string ContentType { get; set; }
/// <summary>
/// Set to 1 to keep the photo in global search results, 2 to hide from public searches.
/// </summary>
[Description("Set to 1 to keep the photo in global search results, 2 to hide from public searches.")]
public string Hidden { get; set; }
}