Downloading AI Class video transcripts from YouTube

If you use YouTube to watch lectures such as the ones that are a part of AI Class, you may want to get a readable transcript of the video. Some of the videos contain a lot of important information, and repeatedly pausing and rewinding the video to take notes is cumbersome and time consuming.

To solve this problem, I’ve contributed a feature to a Tim Smart‘s GreaseMonkey script to allow the user to download all the captions of the video they are currently watching as plain text.

When installed, the script adds two drop down menus by the title of the video allowing you to select the format and language of the transcript.

Download YouTube Video Transcripts

Download text YouTube lecture video transcripts

For those unfamiliar with GreaseMonkey scripts. To install it:

  • Firstly, I’m assuming you are using Firefox as your web browser. If you use Internet Explorer, you can download Firefox here.
  • Once installed, open Firefox and install GreaseMonkey add-on for Firefox by visiting the link and clicking the “Download Now” button. If the “Download Now” button is greyed out, then you are not using using Firefox.
  • Then install the script by visiting the link just mentioned and clicking the green install button on the top right of the page. Restart Firefox and go to the video you want to download a transcript for. Two drop down menus should appear next to the video’s title.

Chrome users can use TamperMonkey, though I haven’t tested that yet.

For those interested, you can fork the source on GitHub.

Scala 2.9.0 on Android

The new 2.9.0 version of the Scala programming language was released recently and in this tutorial, I’ll show you how it can be used to program Android. Read on for an explanation of how Scala compilation is added to the Android build system.

Since Scala runs in the JVM, it should theoretically be possible to use it to write Android applications and various blog posts on the web suggest that others have had success in writing at least basic demo applications. None of the tutorials worked out of the box for me and almost all, if not all were based on very old Android versions. Different versions of Scala releases that I had obtained were also built with different versions of Java and the ones I found were not binary compatible with Android 2.2. So I have pieced together bits and pieces of knowledge that I have read from around the web, hacked around and created a standalone Scala Android application with all the necessary JAR file dependencies.

For this tutorial, I assume that the reader has a familiarity with how to build a basic Android application and also how to build a basic Scala application.

Overview of the build process

The way to get Scala working on Android involves inserting the Scala compilation step into the Android build process. Scala applications are also dependent on the Scala library JAR file which makes the mobile application that uses it very large. In fact, as described in this bug report, the Scala library is too large to go through the dexing process. This means that a second step needs to be inserted into the Android build process: the use of Proguard to reduce the JAR size to just the necessary classes.

The build process therefore involves the following steps:

  1. Compile Scala files
  2. Compile Java file (the Android resource class R.java will still be generated by the build process)
  3. Run Proguard over the output of the compilation steps and dependencies such as scala-library.jar
  4. Convert to dex and package up the application

Adapting the Android application to build Scala code:

In order to insert the above steps into the Android application build process, the Android application needs to be set up to build with ant on the command line. (This is not the only method to set up Android but is the method used in this guide.)

The build.xml file in the root of the Android project directory can then be modified to incorporate the additional steps.

The build.xml uses Ant’s main_rules.xml as a template. This file can be found in
/tools/ant/main_rules.xml in Android SDK 2.2.

Most of main_rules.xml is copy and pasted into build.xml with a few additions: the Scala compilation step and the Proguard step.

The Scala compilation step is achieved by adding the following task to the build.xml. The scala-compiler.jar and scala-library.jar files are included in a subdirectory of the Android project called tools.

<taskdef resource="scala/tools/ant/antlib.xml"
classpath="tools/scala-compiler.jar:tools/scala-library.jar" />
<scalac force="changed" deprecation="on"
destdir="${out.classes.absolute.dir}"
bootclasspathref="android.target.classpath">
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<classpath>
<fileset dir="${jar.libs.absolute.dir}" includes="*.jar" />
<fileset dir="tools" includes="*.jar"/>
</classpath>
</scalac>

Proguard is added to the build process by adding the following task to build.xml. Again the proguard.jar file is included in a subdirectory of the project called tools.

<target name="proguard" depends="compile">
<taskdef resource="proguard/ant/task.properties"
classpath="tools/proguard.jar" />
<proguard>
-injars ${out.classes.absolute.dir}:tools/scala-library.jar(!META-INF/MANIFEST.MF,!library.properties)
-outjars "${out.absolute.dir}/classes.min.jar"
-libraryjars "${android.jar}"
-dontwarn
-dontoptimize
-dontobfuscate
-keep public class * extends android.app.Activity
</proguard>
</target>

Building and running an example project

For this tutorial I have the following installed and working:

  • Android Linux SDK v2.2
  • Scala 2.9.0 (edit: updated to 2.9.1 final now)
  • Proguard 4.4

The HelloScalaOnAndroid project has been pushed to Github and can be cloned from there.

Clone the source from the above URL.

Start the Android 2.2 emulator and type:

ant clean install

If everything is set up properly, the application will have been installed on the running Android emulator.

How to install a new laptop hard disk drive

Here is a step by step visual guide on how to install a new hard disk drive to a laptop.