<commit_before>require 'flickraw'

module FlickrToGooglePhotos
  class Flickr
    include Enumerable

    FLICKR_API = 'https://www.flickr.com/services'
    PER_PAGE = 500

    def initialize(consumer_key, consumer_secret, access_token, access_secret)
      FlickRaw.api_key = consumer_key
      FlickRaw.shared_secret = consumer_secret

      @flickr = FlickRaw::Flickr.new
      @flickr.access_token = access_token
      @flickr.access_secret = access_secret
    end

    def each_photos
      return to_enum(:each_photos) unless block_given?

      count = people_info['photos']['count']

      count.quo(PER_PAGE).ceil.times do |i|
        people_photos(page: i + 1).each do |photo|
          info = photos_info(photo)
          model = FlickrToGooglePhotos::Model::Photo.new(title: info.title,
                                                         url: FlickRaw.url_o(info),
                                                         public: info.visibility.ispublic)

          yield model
        end
      end
    end

    private

    def login
      @_login ||= @flickr.test.login
    end

    def people_info
      @_info ||= @flickr.people.getInfo(user_id: login['id'])
    end

    def people_photos(page:)
      @flickr.people.getPhotos(user_id: login['id'],
                               per_page: PER_PAGE,
                               page: page)
    end

    def photos_info(photo)
      @flickr.photos.getInfo(photo_id: photo.id, secret: photo.secret)
    end
  end
end<commit_msg>Add #each_albums<commit_after>require 'flickraw'

module FlickrToGooglePhotos
  class Flickr
    include Enumerable

    FLICKR_API = 'https://www.flickr.com/services'
    PER_PAGE = 500

    def initialize(consumer_key, consumer_secret, access_token, access_secret)
      FlickRaw.api_key = consumer_key
      FlickRaw.shared_secret = consumer_secret

      @flickr = FlickRaw::Flickr.new
      @flickr.access_token = access_token
      @flickr.access_secret = access_secret
    end

    def each_albums
      return to_enum(:each_albums) unless block_given?

      photosets_list.each do |set|
        model = FlickrToGooglePhotos::Model::Album.new(flickr_id: set.id,
                                                       title: set.title,
                                                       description: set.description)
        yield(model)
      end
    end

    def each_photos
      return to_enum(:each_photos) unless block_given?

      count = people_info['photos']['count']

      count.quo(PER_PAGE).ceil.times do |i|
        people_photos(page: i + 1).each do |photo|
          info = photos_info(photo)
          model = FlickrToGooglePhotos::Model::Photo.new(title: info.title,
                                                         url: FlickRaw.url_o(info),
                                                         public: info.visibility.ispublic)

          yield model
        end
      end
    end

    private

    def login
      @_login ||= @flickr.test.login
    end

    def people_info
      @_info ||= @flickr.people.getInfo(user_id: login['id'])
    end

    def people_photos(page:)
      @flickr.people.getPhotos(user_id: login['id'],
                               per_page: PER_PAGE,
                               page: page)
    end

    def photos_info(photo)
      @flickr.photos.getInfo(photo_id: photo.id, secret: photo.secret)
    end

    def photosets_list
      @_photosets_list ||= @flickr.photosets.getList
    end
  end
end
{'fraction_non_alphanumeric': 0.08651911468812877, 'fraction_numerical': 0.0022995113538373095, 'mean_word_length': 1.8431372549019607, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4542544', 'n_tokens_mistral': 1085, 'n_tokens_neox': 987, 'n_words': 200}