Skip to content

Instantly share code, notes, and snippets.

@PieterT2000
Last active February 4, 2021 15:19
Show Gist options
  • Save PieterT2000/d2401d7b0ccf00abf4b870a8337b722a to your computer and use it in GitHub Desktop.
Save PieterT2000/d2401d7b0ccf00abf4b870a8337b722a to your computer and use it in GitHub Desktop.
Find out how much time you spent on YouTube

Find how much time you spent (wasted?) on YouTube

For MAC users

  1. cp ~/Library/Application\ Support/Google/Chrome/Default/History temp_folder/
  2. Open file in a database viewer (e.g. TablePlus) and run the SQL query found in script.sql.

Note: you will need to copy the file to a temporary location since it's locked when you try to load it into a viewer from it's original location.

SELECT
(
CASE WHEN urls.title LIKE '%youtube%' THEN
'youtube'
ELSE
'other'
END) AS Category,
(sum(visits.visit_duration) / 3600 / 1000000) || ' hours ' || strftime ('%M minutes %S seconds',
sum(visits.visit_duration) / 1000000 / 86400.0) AS 'Time spent'
FROM
urls,
visits
WHERE
urls.id = visits.url
GROUP BY
(
CASE WHEN urls.title LIKE '%youtube%' THEN
'youtube'
ELSE
'other'
END)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment