Ejemplo n.º 1
1
        static void Main(string[] args)
        {
            Flickr flickr = new Flickr(FlickrKey.Key, FlickrKey.Secret);
            Auth auth = null;
            if (File.Exists("key.txt"))
            {
                using (var sr = new StreamReader("key.txt"))
                {
                    flickr.OAuthAccessToken = sr.ReadLine();
                    flickr.OAuthAccessTokenSecret = sr.ReadLine();
                }

            }

            if (!string.IsNullOrEmpty(flickr.OAuthAccessToken) &&
                 !string.IsNullOrEmpty(flickr.OAuthAccessTokenSecret))
            {
                auth = flickr.AuthOAuthCheckToken();
                int g = 56;
            }
            else
            {
                var requestToken = flickr.OAuthGetRequestToken("oob");
                var url = flickr.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Delete);
                Process.Start(url);

                var verifier = Console.ReadLine();

                OAuthAccessToken accessToken = flickr.OAuthGetAccessToken(requestToken, verifier);
                flickr.OAuthAccessToken = accessToken.Token;
                flickr.OAuthAccessTokenSecret = accessToken.TokenSecret;

                using (var sw = new StreamWriter("key.txt", false))
                {
                    sw.WriteLine(flickr.OAuthAccessToken);
                    sw.WriteLine(flickr.OAuthAccessTokenSecret);
                }

                auth = flickr.AuthOAuthCheckToken();
                int y = 56;
            }

            var baseFolder = @"D:\MyData\Camera Dumps\";

            var ex = new PhotoSearchExtras();
            var p = flickr.PhotosSearch(new PhotoSearchOptions(auth.User.UserId){Extras = PhotoSearchExtras.DateTaken | PhotoSearchExtras.PathAlias, });
            var sets = flickr.PhotosetsGetList();
            foreach (var set in sets)
            {
                var setDir = Path.Combine(baseFolder, set.Title);
                if ( Directory.Exists(setDir) )
                {
                    var setPhotos = flickr.PhotosetsGetPhotos(set.PhotosetId, PhotoSearchExtras.DateTaken | PhotoSearchExtras.MachineTags | PhotoSearchExtras.OriginalFormat | PhotoSearchExtras.DateUploaded);
                    foreach(var setPhoto in setPhotos)
                    {
                        if (Math.Abs((setPhoto.DateUploaded - setPhoto.DateTaken).TotalSeconds) < 60)
                        {
                            // Suspicious
                            int s = 56;
                        }

                        string ext = ".jpg";
                        if (setPhoto.OriginalFormat != "jpg")
                        {
                            int xxx = 56;
                        }
                        var filePath = Path.Combine(setDir, setPhoto.Title + ext);

                        if (!File.Exists(filePath))
                        {
                            // try mov
                            filePath = Path.Combine(setDir, setPhoto.Title + ".mov");

                            if (!File.Exists(filePath))
                            {
                                Console.WriteLine("not found " + filePath);
                            }
                        }

                        Console.WriteLine(filePath);
                        if ( File.Exists(filePath))
                        {
                            DateTime dateTaken;
                            if (!GetExifDateTaken(filePath, out dateTaken))
                            {
                                var fi = new FileInfo(filePath);
                                dateTaken = fi.LastWriteTime;
                            }

                            if (Math.Abs((dateTaken - setPhoto.DateTaken).TotalSeconds) > 10)
                            {
                                int hmmm = 56;
                            }
                        }
                    }
                }
            }
            //@"D:\MyData\Camera Dumps\"

            int z =  56;
        }
Ejemplo n.º 2
0
        public FlickrSource(IMetadataStore store, IPlacelessconfig configuration, IUserInteraction userInteraction)
        {
            _metadataStore   = store;
            _configuration   = configuration;
            _userInteraction = userInteraction;
            _flickr          = new FlickrNet.Flickr(API_KEY, API_SECRET);
            _flickr.InstanceCacheDisabled = true;
            var token  = _configuration.GetValue(TOKEN_PATH);
            var secret = _configuration.GetValue(SECRET_PATH);

            token  = "";
            secret = "";

            if (string.IsNullOrWhiteSpace(token) || string.IsNullOrWhiteSpace(secret))
            {
                var    requestToken = _flickr.OAuthGetRequestToken("oob");
                string url          = _flickr.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Write);
                _userInteraction.OpenWebPage(url);
                string approvalCode = _userInteraction.InputPrompt("Please approve access to your Flickr account and enter the key here:");

                var accessToken = _flickr.OAuthGetAccessToken(requestToken, approvalCode);
                token  = accessToken.Token;
                secret = accessToken.TokenSecret;
                _configuration.SetValue(TOKEN_PATH, token);
                _configuration.SetValue(SECRET_PATH, secret);
            }
            _flickr.OAuthAccessToken       = token;
            _flickr.OAuthAccessTokenSecret = secret;
        }
Ejemplo n.º 3
0
        public OAuthAuthorizationObject GetAuthorizationObject(string callbackUrl)
        {
            var flickr = new Flickr();
            var requestToken = flickr.OAuthGetRequestToken(callbackUrl);
            string authorizationUrl = flickr.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Read);

            return new OAuthAuthorizationObject(requestToken.TokenSecret, authorizationUrl);
        }
Ejemplo n.º 4
0
        private async void RequestAuthorization()
        {
            ////GET FROB
            //flickr.AuthGetFrobAsync(new Action<FlickrNet.FlickrResult<string>>(x=>{

            //    if (x.Result != null)
            //    {
            //        frob = x.Result;

            //        //USE FROB TO GET URL FOR USER AUTHENTICATION
            //        string url = flickr.AuthCalcUrl(frob, FlickrNet.AuthLevel.Write);
            //        Windows.System.Launcher.LaunchDefaultProgram(new Uri(url));

            //        Dispatcher.Invoke(Windows.UI.Core.CoreDispatcherPriority.High, new Windows.UI.Core.InvokedHandler((r,a) => {
            //            butRequestAuthorization.IsEnabled = false;
            //            butAuthorizationGiven.IsEnabled = true;
            //        }), this, null);

            //    }
            //}));


            //1. GET THE OAUTH REQUEST TOKEN
            //2. CONSTRUCT A URL & LAUNCH IT TO GET AN "AUTHORIZATION" TOKEN
            await _flickr.OAuthGetRequestTokenAsync("oob", async (x) =>  //{} new Action<FlickrResult<OAuthRequestToken>>(x =>
            {
                if (!x.HasError)
                {
                    rt         = x.Result;
                    string url = _flickr.OAuthCalculateAuthorizationUrl(rt.Token, FlickrNet.AuthLevel.Write);
                    try
                    {
                        await Windows.System.Launcher.LaunchUriAsync(new Uri(url), new Windows.System.LauncherOptions()
                        {
                            DisplayApplicationPicker = true
                        });

                        Dispatcher.RunAsync(
                            Windows.UI.Core.CoreDispatcherPriority.High,
                            new Windows.UI.Core.DispatchedHandler(() =>
                        {
                            butLoginRequest.Visibility = Visibility.Collapsed;
                            butLoginConfirm.Visibility = Visibility.Visible;
                            //butRequestAuthorization.IsEnabled = false;
                            //butAuthorizationGiven.IsEnabled = true;
                            //txtOAuthVerificationCode.IsEnabled = true;
                        })
                            );
                    }
                    catch (Exception ex)
                    {
                        var m = ex.Message;
                    }
                }
                ;
            });
        }
        private async void PageRootLoaded(object sender, RoutedEventArgs e)
        {
            if (AccessToken != null) return;

            var f = new Flickr("dbc316af64fb77dae9140de64262da0a", "0781969a058a2745");
            var requestToken = await GetRequestToken();
            string output;
            var flickrUri = new Uri(f.OAuthCalculateAuthorizationUrl(requestToken.Token, AuthLevel.Delete));
            var webAuthenticationResult = await WebAuthenticationBroker.AuthenticateAsync(
                                                    WebAuthenticationOptions.None,
                                                    flickrUri);

            if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.Success)
            {
                output = webAuthenticationResult.ResponseData;
                AccessToken = await f.OAuthAccessTokenAsync(requestToken.Token, requestToken.TokenSecret, output);

                LoadDataSource(AccessToken);
            }
            else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.ErrorHttp)
            {
                output = "HTTP Error returned by AuthenticateAsync() : " + webAuthenticationResult.ResponseErrorDetail.ToString();
            }
            else if (webAuthenticationResult.ResponseStatus == WebAuthenticationStatus.UserCancel)
            {
                output = "Authentication process was cancelled by the user";
            } 
        }
Ejemplo n.º 6
0
 public string GetAuthUrl(string requestToken)
 {
     return(_flickr.OAuthCalculateAuthorizationUrl(requestToken, AuthLevel.Read));
 }