diff --git a/app.py b/app.py index 57d46fe..4ae5081 100644 --- a/app.py +++ b/app.py @@ -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') @@ -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)