http.tv4.se

http.tv4.se

A different perspective on analytics

About a week ago Disqus – the commenting platform we use on all of our sites – rolled out a new Analytics feature. Besides that it gives us a good overview of number of comments, likes, reactions and people they also express the amount of comments to something you can relate to in a different way:

So now we know that our fiftysix thousand comments on TV4.se equals eight times the book Moby Dick if you read them from first to latest. Sites with fewer comments are compared to a smaller unit: number of SMS.

Three obvious things we missed in testing

This summer we released a new version of the weather site Väderkanalen.se (”The Weather Channel” in Swedish), this time built using the Ruby on Rails framework. Although we have a few tests in the test suite for the site it is far from complete. Three of the things that we have fixed since the release are results of phenomenons that shouldn’t come as a surprise. Three things that are not as certain as death and taxes but not far from it:
  1. There are months with 31 days.
  2. We actually have daylight saving time.
  3. It’s cold in the winter.

One: The first phenomenon was discovered in the end of  August when suddenly the forecasts for September 1st shown on the site was dated as October 1st. It took a while before we realized what happened. The code for setting the date looked something like this:


var forecastDay = new Date(2010,7,31);
undefined
forecastDay
Tue Aug 31 2010 00:00:00 GMT+0200 (CEST)
forecastDay.setMonth(9);
1288476000000
forecastDay.setDate(1);
1285884000000
forecastDay
Fri Oct 01 2010 00:00:00 GMT+0200 (CEST)

Since August have 31 days but September only 30 the 31st day of September really is October 1st. So when we set the day after setting the month we are suddenly in October. The easy fix? To set the day of month before setting the month. The correct fix? To set year, month, and date in the same method call.

Two: Around the end of October a few days before Europe goes back to normal time we see that a number of forecasts are missing. Since we have had trouble with our data supplier, SMHI – the Swedish national weather service, earlier on they are our prime suspect. But when we look at the data files they supply they look to have all data they should have. There is however one thing that look different. After the following Saturday all forecasts are given another timestamp. The forecasts are now for 1pm instead of 2pm. The Javascript code assumes however that the timestamp will be the same as first day of the ten-day forecast. So during transition between daylight saving time and standard time some forecasts will be missing. I guess the error partly can be blamed on our data supplier since the time zone used should have been documented. But mainly it is our fault since the transition shouldn’t have come as a surprise.

Three: When the Flash rendering of the ten-day forecast suddenly went blank for some places up north last week we had a number of theories on the cause. Once again the weather service was a prime suspect but the data was in order so we began to think that it was something different with the data that the Flash code couldn’t handle. And sure enough, it turns out that the code rendering the curve of temperatures didn’t work when all temperatures in the forthcoming ten days were in the sub-zeros (Celsius degrees that is).

Testing: One thing to learn from these errors is to setup a number of tests for all corner cases you can come up with. All three of these errors can be classified as such. All three are also errors in code that runs on the front-end. There are tools for unit testing Javascript code, e.g. Jasmine, but they are not used as much as unit tests for backend code and we have just recently begun to use such tools on our TV4 Play project. There is work on unit testing in Actionscript as well (such as AsUnit), but since the code in question was developed by a third-party we should start by having them better document the work they do. And make it possible for us to test.

Bädda in klipp från alla svenska TV-kanaler

Varje TV-kanal med självaktning har idag en egen play-tjänst med program och videoklipp från de egna programmen utlagda. Vi har förstås vår egen TV4 Play varmast om hjärtat men behovet att diskutera även andra kanalers material. Då vi inte hittade någon som täckte det behov vi hade smällde jag ihop en WordPress-plugin som ska fungera med de olika Play-tjänsterna. Det finns en överhängande risk att saker sluta fungera när de olika tjänsterna ändrar i sina tjänster men vi hoppas på bidrag från intresserade i vårt Github-repository.

Tjänster som stöds är:

Ett tydligt undantag är UR Play som inte stöder inbäddning överhuvudtaget. Upp-och-nedvända världen kan tyckas.

På grund av upphovsrättsliga skäl tillhandahåller inte UR Play möjligheten att bädda in UR:s program på andra webbplatser.

Så installerar du WordPress-pluginen Embed4Play:

  1. Ladda ner pluginen som ZIP-fil genom att trycka på Downloads på pluginens Github-sida.
  2. Packa upp filen och lägg embed4play.php under wp-content/plugins/
    Alternativt kan du använda WordPress’ admin-gränssnitt, klicka på ”Tillägg” -> ”Lägg till nytt” -> ”Ladda upp” och välja ZIP-filen du just laddat ner.
  3. Gå till pluginsidan i WordPress’ admin-gränssnitt och aktivera pluginen.
  4. Nu kan du lägga till videoklipp i bloggposter

Så lägger du till ett videoklipp med Embed4Play:

  1. I tjänsten som innehåller det aktuella klippet får du luska ut det aktuella id-numret för klippet. Det är oftast ett helt numeriskt id och du hittar det antingen i URL-en till klippet eller i embed-koden som videospelaren ger ifrån sig när man klickar ”Dela”, ”Bädda in” eller liknande.
  2. I ditt blogginlägg skriver du sedan in taggen för den aktuella tjänsten och id-numret:
    [svtplay id=2238016]
    I det här fallet läggs ett klipp med id-nummer 2238016 från SVT Play in. När du förhandsgranskar ska du kunna se klippet istället för denna kod. Resultatet bör bli detta:

Taggarnas namn:

  • tv4play
  • svtplay
  • kanal5play
  • tv3play
  • tv6play
  • tv8play
  • kanal9play
  • expressentv

Övriga parametrar:

size: Kan sättas till small, medium eller large för olika storlekar på videospelaren. (Kan även sättas på pixelnivå, se nedan)

width: Videospelarens bredd i antal pixlar

height: Videospelarens höjd i antal pixlar

Short summary in English: This blog post describes a WordPress plugin that allows users of WordPress.org blogs to embed video clips from the major media outlets in Sweden. By entering the shortcode [svtplay id=2238016] where svtplay is the name of the service (the other are listed above) and the number after id is the internal id of the clip within that service you get the correct Flash video player embedded. This plugin is available via our Github repository.

Svenska eller english?

Multilingual Scrabble
Multilingual Scrabble by urbanmkr

Ny blogg! Som vi antingen kör vi svenska – vilket är det mest naturliga – eller så blir det engelska. Kanske lite mer ansträngt men fördelar med att vi kan nå ut längre, bland annat till leverantörer, kollegor och partners som inte talar svenska. Det finns bra argument för båda alternativen.

Men språket behöver vi inte bestämma nu. Bättre köra igång, testa lite och känna oss för så att vi sen kan fatta ett beslut baserat på vad vi lärt oss. Vi kan kalla det ”beta”.

Välkomna hit!

Nyare21
 
NU
 
Visa hela tablån