mirror of
https://github.com/dmunozv04/iSponsorBlockTV.git
synced 2025-12-17 21:18:59 +03:00
Merge pull request #4 from HaltCatchFire/fix-starting-in-segment
Add logic for when video starts in a segment
This commit is contained in:
18
main.py
18
main.py
@@ -91,14 +91,16 @@ 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)
|
||||||
await rc.set_position(position)
|
await rc.set_position(position)
|
||||||
|
|||||||
Reference in New Issue
Block a user