System restarting, wait...


15 Feb 2018

So their product leaves a residue and the fix is for the user to re apply oil to the wooden surface. Insert "you are using it wrong" comment here.
https://gizmodo.com/apple-s-homepod-can-apparently-damage-your-furniture-1823001315


14 Feb 2018

Great! I lost my yubikey again and I need it to boot my laptop


23 Jan 2018

Some pictures from the first day of the Amazon Go Store. We got some small items and thankfully the line was not too long either. Maybe this is the future, we shall see.


Amazon Post Holiday Party

20 Jan 2018 - Tags: Amazon, Party

Some pictures of our second year going to the Amazon After Holiday Party. Although this time the venue was too packed and really it was not as good as last time. :/


Another night around Capitol Hill

15 Jan 2018 - Tag: random

The weather was nice on Saturday so we decided to go out and enjoy the day.


12 Jan 2018

Friday after work. The connector stop is dead.


Getting Youtube data with Python

10 Jan 2018 - Tags: programming, python, youtube

This is done with python 2 becuase most of the Youtube DATA libraries seem to support Python 2 better than 3. There may be versions of some of the libraries for Python 3 but I did not spend anytime investigating this route.

This link goes over most of the setup process pretty well: https://developers.google.com/youtube/v3/getting-started

  1. Go to the developers console and create a new project https://console.developers.google.com/

  2. Now on the project page go to Credentials and create an OAuth 2 Client ID of type Other. Now download the json file which we will use to authenticate our app.

  3. To install the Youtube Data library you can use pip. I got the instructions from the Youtube api-samples github page. As previously mentioned, we will use Python2.
    pip install --upgrade google-api-python-client
    
  4. Now install other google libraries that will also be needed
    pip install --upgrade google-auth google-auth-oauthlib google-auth-httplib2
    
  5. Now move the downloaded file and rename it to client_secrets.json, since that is what the script is expecting. I am using my_uploads.py as a reference. If you run this script now you will be prompted to visit a URL and enter the resultingauthorization code.
    cramsan@kururu ~/git/cramsan.github.io/scripts $ python2 demo.py 
    Please visit this URL to authorize this application: https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=743336358314-o1grlivilob3pb4k3ra4b45kulgu20oa.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fyoutube.readonly&state=plvu3RkeSZL8Laj3wtz6IHsuvXBgY9&prompt=consent&access_type=offline
    Enter the authorization code:
    
  6. This happens becuase the OAuth2 credentials previously created requiere manual copy/paste. There are four types of redirect methods and in this case we are are using the Manual copy/paste mode. Now you have everything you need to access the Youtube Data API. You can run the examples from the Youtube api-samples github page or the scrips from the repo of this blog.

Acessing the API is rather simple.

  • Create the YoutubeAPI object
def get_authenticated_service():
  flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRETS_FILE, SCOPES)
  credentials = flow.run_console()
  return build(API_SERVICE_NAME, API_VERSION, credentials = credentials)
youtube = get_authenticated_service()
  • Now get the list of uploaded videos. This function will return the Id of the playlist that represents the upload list of the authenticated channel
def get_my_uploads_list():
  # Retrieve the contentDetails part of the channel resource for the
  # authenticated user's channel.
  channels_response = youtube.channels().list(
    mine=True,
    part='contentDetails'
  ).execute()
  for channel in channels_response['items']:
    # From the API response, extract the playlist ID that identifies the list
    # of videos uploaded to the authenticated user's channel.
    return channel['contentDetails']['relatedPlaylists']['uploads']
  return None
  • Now that you have the Id of the uploads playlist, you can use it to iterate over every video
def list_my_uploaded_videos(uploads_playlist_id):
  # Retrieve the list of videos uploaded to the authenticated user's channel.
  playlistitems_list_request = youtube.playlistItems().list(
    playlistId=uploads_playlist_id,
    part='snippet',
    maxResults=5
  )
  print 'Videos in list %s' % uploads_playlist_id
  while playlistitems_list_request:
    playlistitems_list_response = playlistitems_list_request.execute()
    # Print information about each video.
    for playlist_item in playlistitems_list_response['items']:
      title = playlist_item['snippet']['title']
      video_id = playlist_item['snippet']['resourceId']['videoId']
      print '%s (%s)' % (title, video_id)
    playlistitems_list_request = youtube.playlistItems().list_next(
      playlistitems_list_request, playlistitems_list_response)

05 Jan 2018

Super Sentai looks like the kind of show I should have started watching a long time ago.


03 Jan 2018

They arrived! Now I am waiting for @empathyawaits so we can set them up together. #Pixel2


27 Dec 2017

FYI to anyone updating their kernel. There is a nasty bug in 4.13 causing BIOS corruption in some laptops, be careful. This bug could permanently leave your BIOS in an unrecoverable state. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1734147


23 Dec 2017

Trying a variety of Portland beers.


23 Dec 2017

Having some tea at the Lan Su Garden in Portland.


21 Dec 2017

Christmas-opolys! Made while at work.


21 Dec 2017

I hate this weather with such passion. Forecast for today is between -3C and 4C. At least it's not raining. What a way to start the day -_-


05 Dec 2017

Setting up my office for the next two weeks.


Page: 3/12