Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/credits #7

Merged
merged 10 commits into from
Feb 18, 2023
Merged

Feature/credits #7

merged 10 commits into from
Feb 18, 2023

Conversation

danrahn
Copy link
Owner

@danrahn danrahn commented Feb 18, 2023

feature/credits, V1

Add initial support for 'credits' markers in addition to 'intro'. In this PR, only TV episodes are supported, but movie integration is planned for the final release, likely 2.0.

Summary of major changes (some of which aren't specific to credits support):

  • Backup database:
    • Credits specific changes: add marker_type and final columns to indicate the type of marker (intro/credits), and if it's a credits marker, whether it indicates the final marker that will invoke the PostPlay screen in Plex.
    • General changes: Sometime in late 2022 Plex changed the taggings table to use epoch timestamps instead of datetime strings. Follow suit by
      • Converting the existing modified_at/created_at/recorded_at fields from datetime to integer epoch timestamps.
      • Adding a user_created column, which servers the same purpose that appending * to the modified_at date used to.
      • Update Plex's taggings table to adjust hacked thumb_url timestamps to epoch timestamps, and since we can't add a column and adding * to an integer doesn't make sense, use a negative value to indicate user created markers.
  • Credits showed that a marker's index does not correlate to it's "position" in the episode (commercial skips probably could have told me that). Use the time_offset (start) instead, and ensure things are sorted client-side. Update various index-based calculations to instead use the already-sorted marker array that various features hold on to.
    • TODO: get rid of the concept of re-indexing entirely, outside of adjusting for deleted markers.
  • Server commands: add markerType/final parameters to relevant actions (add, edit, and bulk_add).
  • Replace the marker table's Index column with the marker type. When adding/editing, make it a dropdown to select from the various marker types. If the Ctrl+Shift+E command is invoked (move the end timestamp to the end of the episode), automatically switch the type to Credits.
  • [Unrelated to Credits]: Fix error hints when bulk adding - ensure errors/warnings are shown when the new marker starts beyond the episode's duration, and when it completely encapsulates an existing marker.

Note: Tests do not pass. They've been re-worked for some new features, but not everything.

Update the db schema to support a marker_type (intro vs credits), and a
'final' field indicating whether the marker goes to the end of the item.
Include extra information for credits distinction to Plex db queries,
and add that information to action recording.
Various bugs were introduced when attempting to add credits info to
Plex queries. Also adjust tests to include credit info, but nothing
really tests it yet.
While the client only ever adds intros/final=0, the endpoints can in-
theory add credit markers that are final/not final.
In late 2020 Plex switched their timestamps from datetime strings to
epoch timestamps. Follow that by bundling the conversion into the V4
schema upgrade that includes Credits support. Adjust the rest of the
pipeline to handle the new time format.

Also rework the storage of "user created":
* In the marker backup database, add a user_created column instead of
  postfixing a '*' to the modified date.
* In the Plex DB, make the modified timestamp negative instead of
  the similar '*' postfixing.
In addition to switching the backup action's time format to epoch
timestamps, the hacked thumb_url values in the Plex database also need
to be updated, as it's not included in Plex's own schema update.
Allow users to set the marker type when doing basic add/edit/delete
operations. Also take into account that Plex doesn't care about keeping
indexes "properly" sorted by sorting them by the start offset ourselves,
not relying on any set order from the server. This change also begins to
document places that can/should be updated to not be so strict about
index ordering.

On top of that, the following smaller adjustments were made to ensure
proper support:
* Add marker type/final to edit command parameters
* Switch index column in the table to marker type, and make it a SELECT
  when adding/editing.
* Ensure Plex queries are sorted by time_offset instead of index.

NOTE: It's almost guaranteed that tests are currently broken. I'll need
to rethink some things as far as validating proper order goes. Bulk
operations have also not been considered yet.
Fix two issues with bulk-add hints:
* With 'Fail' action, we didn't catch cases where the new marker
  completely encompasses an existing marker. Correctly mark them red.
* With 'Merge' action, the 'end' column wouldn't show yellow if the
  existing marker determined the new end bound.

Also fix checkBulkAdd/bulkAdd parameters passed to the server.
Allow the user to choose whether to add intro or credits markers in the
bulk-add overlay. Additionally,
* Fix more error hinting - show the right error when the start is
  greater than the length of the episode.
* If a bulk-added marker ends at or beyond the end of the episode, mark
  it final.
@danrahn danrahn self-assigned this Feb 18, 2023
@danrahn danrahn closed this Feb 18, 2023
@danrahn danrahn reopened this Feb 18, 2023
@danrahn danrahn merged commit 8ffc447 into main Feb 18, 2023
danrahn added a commit that referenced this pull request Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant