mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-11 06:26:44 +03:00
Add logic for when video starts in a segment
This commit is contained in:
16
main.py
16
main.py
@@ -81,13 +81,15 @@ async def get_segments(vid_id, web_session, categories = ["sponsor"]):
|
|||||||
|
|
||||||
|
|
||||||
async def time_to_segment(segments, position, rc):
|
async def time_to_segment(segments, position, rc):
|
||||||
future_segments = []
|
for segment in segments:
|
||||||
for i in segments:
|
if position < 2 and (position >= segment[0] and position < segment[1]):
|
||||||
if i[0] > position:
|
next_segment = [position, segment[1]]
|
||||||
future_segments.append(i)
|
break
|
||||||
next_segement = future_segments[0]
|
if segment[0] > position:
|
||||||
time_to_next = next_segement[0] - position
|
next_segment = segment
|
||||||
await skip(time_to_next, next_segement[1], rc)
|
break
|
||||||
|
time_to_next = next_segment[0] - position
|
||||||
|
await skip(time_to_next, next_segment[1], rc)
|
||||||
|
|
||||||
async def skip(time_to, position, rc):
|
async def skip(time_to, position, rc):
|
||||||
await asyncio.sleep(time_to)
|
await asyncio.sleep(time_to)
|
||||||
|
|||||||
Reference in New Issue
Block a user