Skip to content

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
firofame committed Jul 5, 2024
1 parent 1f91e92 commit ae079fe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
with open('handles.txt', 'r') as f:
handles = [tuple(line.strip().split(',')) for line in f]

# Create an empty list to store the channel data
channel_data = []

# Write the playlist file
with open('playlist.m3u8', 'w') as f:
f.write('#EXTM3U\n\n')
Expand All @@ -29,8 +32,21 @@
channel_name = data['contents']['twoColumnWatchNextResults']['results']['results']['contents'][1]['videoSecondaryInfoRenderer']['owner']['videoOwnerRenderer']['title']['runs'][0]['text']
image_url = data['contents']['twoColumnWatchNextResults']['results']['results']['contents'][1]['videoSecondaryInfoRenderer']['owner']['videoOwnerRenderer']['thumbnail']['thumbnails'][-1]['url']

# Extract the channel ID
channel_id = data['contents']['twoColumnWatchNextResults']['results']['results']['contents'][1]['videoSecondaryInfoRenderer']['owner']['videoOwnerRenderer']['title']['runs'][0]['navigationEndpoint']['browseEndpoint']['browseId']

# Construct the M3U8 URL for the channel's live stream
m3u8_url = f'https://live.firofame.workers.dev/?@={handle}'

# Write the metadata and URL to the playlist file
f.write(f'#EXTINF:-1 tvg-logo="{image_url}" group-title="{group}", {channel_name}\n{m3u8_url}\n\n')

# Add the channel data to the list
channel_data.append({
'channel_name': channel_name,
'channel_id': channel_id
})

# Write the channel data to a JSON file
with open('playlist.json', 'w') as f:
json.dump(channel_data, f)

0 comments on commit ae079fe

Please sign in to comment.