Skip to content

Commit

Permalink
Release v2.1.1 (#49)
Browse files Browse the repository at this point in the history
* fix: bug with timestamp parsing
* refactor: ensure all occurences of '\n' are replaced in the timestamp string
  • Loading branch information
nrednav authored Apr 13, 2024
1 parent 0213572 commit 868b94c
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v2.1.1] - 2024-04-13

### Fixed

- Fixed an issue with timestamp strings not being parsed correctly leading to an
inaccurate total duration being calculated
- It appears something may have changed recently with how timestamps are
rendered since the timestamp DOM element now has a chance to contain
duplicate timstamp strings, e.g. `04:20\n 04:20`
- So when `convertTimestampToSeconds` gets such a timestamp and attempts to
split it by `:`, the end result is 4 time components: `[4, 20, 4, 20]`
- To fix this, `getTimestampFromVideo` will now use a regular expression to
extract the timestamp from the DOM element

## [v2.1.0] - 2024-04-07

### Added

- Added ability to sort playlists by different criteria (index, duration, views, channel name, upload date)
- Added i18n support & language translations:
- English (en, en-GB, en-IN, en-US)
- Spanish (es, es-419, es-us)
- Portuguese (pt-PT, pt-BR)
- Chinese (zh-Hans-CN, zh-Hant-TW)
- Added & updated documentation (README, testing, adding translations)

### Changed

- Migrated package manager from npm to pnpm
- Refactored several parts of codebase to reduce complexity

### Fixed

- Fixed several bugs
- Bug with mutation observer not disconnecting when navigating between playlists
- Bug where timestamps were not being summed properly
- Addressed vulnerabilities reported by pnpm audit and dependabot
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "An extension to calculate & display the total duration of a youtube playlist.",
"author": "nrednav",
"private": true,
"version": "2.1.0",
"version": "2.1.1",
"type": "module",
"engines": {
"node": ">=20",
Expand Down
8 changes: 7 additions & 1 deletion src/shared/modules/timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ export const getTimestampFromVideo = (video) => {
const timestamp = timestampElement.innerText;
if (!timestamp) return null;

const timestampAsSeconds = convertTimestampToSeconds(timestamp);
// Ref: Timestamp regex from https://stackoverflow.com/a/8318367
const timestampSanitized = timestamp
.trim()
.replace(/\n/g, "")
.match(/((?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d))/)[0];

const timestampAsSeconds = convertTimestampToSeconds(timestampSanitized);
return timestampAsSeconds;
};

0 comments on commit 868b94c

Please sign in to comment.