Simplify Media Identification Function #7

Merged
ProfessorDey merged 1 commit from patch-1 into master 2018-04-25 18:40:14 +02:00
ProfessorDey commented 2018-04-19 19:59:39 +02:00 (Migrated from github.com)

Rebased from LBRY/lbry-app PR# 1304 with corrections requested by Codacy (Though may still complain regarding spacing).

This just makes the code for finding documents a lot easier. the regex patterns and the media type are converted into keypairs, [regex, mediatype] which is then reduced to a single value, which will either be the original filename if there are no matching extensions, or the mediatype. So long as the mediatype does not contain an extension at the end of the string, this system should work far more simply.

This will also allow for easier addition of new extensions to the function, so long as they all follow the same pattern for the regex:
^ = Start of string
.+ = 1 or more characters of any type
. = A literal dot
(a|b|c) = A list of ORed extensions within a capture group '( )'
$ = End of string, so it is certain this is the actual extension of the filename

Won't be hard to add things like Archives, Executables, etc with just a single extra line now.

Rebased from LBRY/lbry-app PR# 1304 with corrections requested by Codacy (Though may still complain regarding spacing). This just makes the code for finding documents a lot easier. the regex patterns and the media type are converted into keypairs, [regex, mediatype] which is then reduced to a single value, which will either be the original filename if there are no matching extensions, or the mediatype. So long as the mediatype does not contain an extension at the end of the string, this system should work far more simply. This will also allow for easier addition of new extensions to the function, so long as they all follow the same pattern for the regex: ^ = Start of string .+ = 1 or more characters of any type . = A literal dot (a|b|c) = A list of ORed extensions within a capture group '( )' $ = End of string, so it is certain this is the actual extension of the filename Won't be hard to add things like Archives, Executables, etc with just a single extra line now.
tzarebczan commented 2018-04-23 14:43:17 +02:00 (Migrated from github.com)

@seanyesmunt please review when you get a moment. See my previous comments on https://github.com/lbryio/lbry-app/pull/1304#issuecomment-381777069, let me know if we need to discuss.

@seanyesmunt please review when you get a moment. See my previous comments on https://github.com/lbryio/lbry-app/pull/1304#issuecomment-381777069, let me know if we need to discuss.
tzarebczan commented 2018-04-24 18:22:00 +02:00 (Migrated from github.com)

@seanyesmunt should we discuss this or can it be merged?

@seanyesmunt should we discuss this or can it be merged?
neb-b (Migrated from github.com) approved these changes 2018-04-25 18:40:03 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: LBRYCommunity/lbry-redux#7
No description provided.