Stitch-For-Roku icon indicating copy to clipboard operation
Stitch-For-Roku copied to clipboard

Triaging Remaining Upstream Code

Open elsiehupp opened this issue 1 year ago • 0 comments

To find remaining upstream code, I concatenated all the text files from 268187c and all the text files from 4730a81 and put them through a plagiarism checker.

Instances

I found the following overlaps, most of which are only partial matches, amounting to approximately 3% of the total codebase.

1. Much of CustomVideo

You thought this might be from Jellyfin?

2. getRelativeTimePublished

function getRelativeTimePublished(timePublished as string) as string
    secondsSincePublished = createObject("roDateTime")
    secondsSincePublished.FromISO8601String(timePublished)
    currentTime = createObject("roDateTime").AsSeconds()
    elapsedTime = currentTime - secondsSincePublished.AsSeconds()

    elapsedTime = Int(elapsedTime / 60)
    if elapsedTime < 60
        if elapsedTime = 1
            return "1 minute ago"
        else
            return elapsedTime.ToStr() + " minutes ago"
        end if
    end if

    elapsedTime = Int(elapsedTime / 60)
    if elapsedTime < 24
        if elapsedTime = 1
            return "1 hour ago"
        else
            return elapsedTime.ToStr() + " hours ago"
        end if
    end if

    elapsedTime = Int(elapsedTime / 24)
    if elapsedTime < 30
        if elapsedTime = 1
            return "1 day ago"
        else
            return elapsedTime.ToStr() + " days ago"
        end if
    end if

    elapsedTime = Int(elapsedTime / 30)
    if elapsedTime < 12
        if elapsedTime = 1
            return "Last month"
        else
            return elapsedTime.ToStr() + " months ago"
        end if
    end if

    elapsedTime = Int(elapsedTime / 12)
    if elapsedTime = 1
        return "1 year ago"
    else
        return elapsedTime.ToStr() + " years ago"
    end if

end function

3. numberToText

sub numberToText(number) as object
    s = StrI(number)
    result = ""
    if number >= 100000 and number < 1000000
        result = Left(s, 4) + "K"
    else if number >= 10000 and number < 100000
        result = Left(s, 3) + "." + Mid(s, 4, 1) + "K"
    else if number >= 1000 and number < 10000
        result = Left(s, 2) + "." + Mid(s, 3, 1) + "K"
    else if number < 1000
        result = s
    end if
    return result
end sub

4. Various Snippets from Chat

if tcpListen.GetCountRcvBuf() > 0
    while not get = Chr(10)
        get = tcpListen.ReceiveStr(1)
        '? "receive Status " tcpListen.Status()
        received += get
    end while
end if
if tcpListen.GetCountRcvBuf() = 0 and tcpListen.IsReadable()
    tcpListen = createObject("roStreamSocket")
    tcpListen.SetSendToAddress(addr)
    tcpListen.Connect()
    tcpListen.SendStr("CAP REQ :twitch.tv/tags twitch.tv/commands" + Chr(13) + Chr(10))
    tcpListen.SendStr("PASS SCHMOOPIIE" + Chr(13) + Chr(10))
    tcpListen.SendStr("NICK justinfan32006" + Chr(13) + Chr(10))
    tcpListen.SendStr("JOIN #" + m.top.channel + Chr(13) + Chr(10))
end if
if not received = ""
    if Left(received, 4) = "PING"
        tcpListen.SendStr("PONG :tmi.twitch.tv" + Chr(13) + Chr(10))
    else
        queue.unshift(received)
        receivedNewMessage = true
    end if
end if
function buildUsername(display_name, color)
    username = createObject("roSGNode", "SimpleLabel")
    username.text = display_name
    if color = ""
        color = "FFFFFF"
    end if
    username.color = "0x" + color + "FF"
    username.visible = true
    username.fontSize = m.font_size
    username.fontUri = "pkg:/fonts/KlokanTechNotoSansCJK-Bold.otf"
    return username
end function
sub onEnterChannel()
    ' ? "Chat >> onEnterChannel > " m.top.channel
    if get_user_setting("ChatWebOption", "true") = "true"
        m.chat = m.top.findnode("ChatJob")
        m.chat.forceLive = m.top.forceLive
        ' m.chat.observeField("nextComment", "onNewComment")
        m.chat.observeField("nextCommentObj", "onNewCommentObj")
        ' m.chat.observeField("clientComment", "onNewComment")
        m.chat.channel = m.top.channel
        m.chat.control = "stop"
        m.chat.control = "run"
    end if
    m.EmoteJob = m.top.findnode("EmoteJob")
    m.EmoteJob.channel_id = m.top.channel_id
    m.EmoteJob.channel = m.top.channel
    m.EmoteJob.control = "run"
end sub
sub extractMessage(section) as object
    m.userstate_change = false
    words = section.Split(" ")
    if words[2] = "USERSTATE"
        m.userstate_change = true
    end if
    message = ""
    for i = 4 to words.Count() - 1
        message += words[i] + " "
    end for
    return message
end sub
function buildBadges(badges)
    group = createObject("roSGNode", "Group")
    group.visible = true
    badge_translation = 0
    for each badge in badges
        if badge <> invalid and badge <> ""
            if m.global.twitchBadges <> invalid
                if m.global.twitchBadges[badge] <> invalid
                    poster = createObject("roSGNode", "Poster")
                    poster.uri = m.global.twitchBadges[badge]
                    poster.width = m.badge_size
                    poster.height = m.badge_size
                    poster.visible = true
                    poster.translation = [badge_translation, 0]
                    group.appendChild(poster)
                    badge_translation += (m.badge_size + (m.badge_size / 6))
                end if
            end if
        end if
    end for
    return group
end function

5. FollowedStreamsBar

Various snippets, including:

sub onKeyEvent(key, press) as boolean
    handled = false
    if press
        if key = "left"
            return true
        end if
        if key = "up"
            if m.currentIndex = 0
                return false
                'tofix: add behaviour to move to top bar'
            end if
            if m.currentIndex - 1 >= 0
                m.children[m.currentIndex].focused = false
                m.currentIndex -= 1
                if m.currentIndex < m.min
                    for each stream in m.children
                        stream.translation = [m.xTranslation, (stream.translation[1] + 60)]
                        ' stream.translation = "[9," + (stream.translation[1] + 60).ToStr() + "]"
                        if stream.translation[1] > 0
                            stream.visible = true
                        end if
                    end for
                    m.min -= 1
                    m.max -= 1
                end if
                m.children[m.currentIndex].focused = true
            end if
            handled = true
        else if key = "down"
            if m.currentIndex + 1 < m.top.getChildCount() - 1
                m.children[m.currentIndex].focused = false
                if m.children[m.currentIndex + 1] <> invalid
                    m.currentIndex += 1
                end if
                if m.currentIndex > m.max
                    for each stream in m.children
                        stream.translation = [m.xTranslation, (stream.translation[1] - 60)]
                        ' stream.translation = "[9," + (stream.translation[1] - 60).ToStr() + "]"
                        if stream.translation[1] <= 0
                            stream.visible = false
                        end if
                    end for
                    m.min += 1
                    m.max += 1
                end if
                m.children[m.currentIndex].focused = true
            end if
            handled = true
        else if key = "OK"
            if m.children[m.currentIndex] <> invalid
                m.top.streamerSelected = m.children[m.currentIndex].twitch_id
                m.top.contentSelected = m.children[m.currentIndex].content
                m.children[m.currentIndex].focused = false
                handled = true
            end if
        end if
    end if
    return handled
end sub

What to do?

Some of these residual snippets are fairly minimal and would be relatively easy to replace. Others are probably not big enough priorities to deal with.

One way of triaging these could be to put a header comment in each affected file (and above each affected function) mentioning its licensing issues and then to put a header comment reading 'SPDX-License-Identifier: Unlicense in every other file. (The licensing for image and font assets should also be listed where relevant.)

As an aside, the SPDX guide mentions the option of specifying a choice of licenses for licensees. So if you want to be more broad, you could specify something like 'SPDX-License-Identifier: 0BSD OR Unlicense.

How does this sound?

elsiehupp avatar Sep 23 '23 19:09 elsiehupp