Не срабатывает скрипт проверки плейлистов

satfan

Пользователь
Пользователь
Апр 21, 2020
98
6
8
IDLE (Python 3.10 64-bit)
Windows 10
---------------------------
Есть такой скрипт EditBot - запускаю, ошибок нет.
Нет и результата его работы.
Python:
# -*- coding: utf-8 -*-

# Раздел подключения внешних модулей
import os
import time
import urllib.request, urllib.parse, urllib.error

# Раздел объявления констант
LENDATA = 1364
TIMEOUT = 8

# Раздел пользовательских функций
def namePLIST():
    namefile = os.listdir(os.getcwd())
    for name in namefile:
        if name.find('.m3u') != -1:
            return name
    print('Плейлист не найден')
    time.sleep(2)
    exit()

def updatePLIST(namefile, newplist):
    plistfile = open('new_' + namefile, 'w')
    plistfile.write(newplist)
    plistfile.close()
    print('Плейлист обновлён')
    time.sleep(2)

def vrfSTREAM(link, bufline):
    try:
        name = bufline.split(',')[1].decode('utf-8')
        stream = urllib.request.urlopen(link)
        data = stream.read(LENDATA)
        if len(data) == LENDATA:
            print('%s - рабочий' % name)
            return True
    except:
        pass
    print('%s - не рабочий' % name)
    return False

def readPLIST(namefile):
    newline = ''
    plistfile = open(namefile, 'r')
    for line in plistfile.readlines():
        if line.find('EXTM3U') != -1:
            newline = newline + line
        elif line.find('EXTINF') != -1:
            bufline = line
        elif (line.find('/udp/') != -1 and
            vrfSTREAM(line, bufline)):
            newline = newline + bufline + line
    plistfile.close()
    return newline

def startBOT():
    print('Привет, EditBot успешно стартовал')
    urllib.socket.setdefaulttimeout(TIMEOUT)
    namefile = namePLIST()
    newplist = readPLIST(namefile)
    updatePLIST(namefile, newplist)
Подскажите что не так в скрипте ?
 

Форум IT Специалистов