Пример #1
0
def PhotoSet(id):  
  oc = ObjectContainer(view_group='Pictures')
  access_token = FlickRAuthToken.from_string(Dict['accesstoken'])
  request = FlickRRequest()      
  defaults = {      
    'api_key': FLICKR_KEY,
    'format': 'rest',
    'method': 'flickr.photosets.getPhotos',
    'extras': 'date_taken, url_q, url_o',
    'photoset_id': id
  }      
  response = request.make_query(access_token = access_token, query = 'https://api.flickr.com/services/rest', params = defaults, returnURL = False)
  data = response.read()    
  photos = ET.fromstring(data)
  for item in photos.findall('.//photo'):  
    thumb = item.find('.').attrib['url_q']
    id = item.find('.').attrib['id']
    date_taken = item.find('.').attrib['datetaken']
    date = Datetime.ParseDate(date_taken)
    url_o = item.find('.').attrib['url_o']
    oc.add(PhotoObject(          
      key = url_o,
      rating_key = id,
      title = date_taken,     
      thumb = thumb,
      summary = "",
      originally_available_at = date)
    )
  return oc  
Пример #2
0
def PhotoSet(id):
    oc = ObjectContainer(view_group='Pictures')
    access_token = FlickRAuthToken.from_string(Dict['accesstoken'])
    request = FlickRRequest()
    defaults = {
        'api_key': FLICKR_KEY,
        'format': 'rest',
        'method': 'flickr.photosets.getPhotos',
        'extras': 'date_taken, url_q, url_o',
        'photoset_id': id
    }
    response = request.make_query(access_token=access_token,
                                  query='https://api.flickr.com/services/rest',
                                  params=defaults,
                                  returnURL=False)
    data = response.read()
    photos = ET.fromstring(data)
    for item in photos.findall('.//photo'):
        thumb = item.find('.').attrib['url_q']
        id = item.find('.').attrib['id']
        date_taken = item.find('.').attrib['datetaken']
        date = Datetime.ParseDate(date_taken)
        url_o = item.find('.').attrib['url_o']
        oc.add(
            PhotoObject(key=url_o,
                        rating_key=id,
                        title=date_taken,
                        thumb=thumb,
                        summary="",
                        originally_available_at=date))
    return oc
Пример #3
0
def MainMenu():
    oc = ObjectContainer(no_cache=True)
    oc.add(PrefsObject(title="Preferences"))
    # Attempt to log in
    logged_in = Account.LoggedIn()
    if not logged_in:
        logged_in = Account.TryLogIn()
    if logged_in:
        access_token = FlickRAuthToken.from_string(Dict['accesstoken'])
        request = FlickRRequest()
        defaults = {
            'api_key': FLICKR_KEY,
            'format': 'rest',
            'method': 'flickr.photosets.getList',
            'primary_photo_extras': 'url_m'
        }
        response = request.make_query(
            access_token=access_token,
            query='https://api.flickr.com/services/rest',
            params=defaults,
            returnURL=False)
        photosets = ET.fromstring(response.read())
        for item in photosets.findall('.//photoset'):
            title = item.find('./title').text
            thumb = item.find('./primary_photo_extras').attrib['url_m']
            photosetid = item.find('.').attrib['id']
            oc.add(
                DirectoryObject(key=Callback(PhotoSet, id=photosetid),
                                title=title,
                                thumb=thumb))
    return oc
Пример #4
0
def MainMenu():   
  oc = ObjectContainer(no_cache = True)
  oc.add(PrefsObject(title = "Preferences"))
  # Attempt to log in
  logged_in = Account.LoggedIn()
  if not logged_in:    
    logged_in = Account.TryLogIn()
  if logged_in:
    access_token = FlickRAuthToken.from_string(Dict['accesstoken'])
    request = FlickRRequest()      
    defaults = {      
      'api_key': FLICKR_KEY,
      'format': 'rest',
      'method': 'flickr.photosets.getList',
      'primary_photo_extras': 'url_m'
    }      
    response = request.make_query(access_token = access_token, query = 'https://api.flickr.com/services/rest', params = defaults, returnURL = False)    
    photosets = ET.fromstring(response.read())
    for item in photosets.findall('.//photoset'):    
      title = item.find('./title').text     
      thumb = item.find('./primary_photo_extras').attrib['url_m']      
      photosetid = item.find('.').attrib['id']
      oc.add(DirectoryObject(key = Callback(PhotoSet, id = photosetid), title = title, thumb  = thumb))
  return oc