def entry_playlist(purl): id = purl[-10:] purl = "http://music.163.com/api/playlist/detail?id={}&upd".format(id) headers = { 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36', 'Accept-Encoding': 'gzip, deflate', 'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', 'connection': 'keep-alive', 'cache-control': 'no-cache', 'Referer': 'http://music.163.com/' } s = BeautifulSoup( requests.get(purl, headers=headers).content, 'html.parser') pl = json.loads(s.text)['result'] pid = pl['id'] pname = pl['name'] pcreator = pl['creator']['nickname'] c = connection_mysql.connect() try: if c.wplaylist(playlist.playlist(pid, pname, pcreator)): print('歌单信息录入成功 ' + pname) for i in pl['tracks']: if c.wsong(song.song(i['id'], i['name'], "")): print('歌曲信息录入成功 ' + i['name']) else: print('此歌曲信息已存在 ' + i['name']) else: print('歌单信息已存在 ' + pname) except Exception: print('music_main出现异常') finally: c.connect_close()
def createPlaylist(self, channelsResp): #channelsResp = channelsResp.encode('utf8') #channelsResp = httpClient.encoded_item(httpClient) #channelsResp = channelsResp.encode('ascii', 'ignore') playlistManager = playlist.playlist() playlistManager.init('telewizjada') #log.error('Telewizjada: ' + str(channelsResp)) jsonChannels = json.loads(channelsResp) count = 0 for cat in jsonChannels['categories']: catId = cat['Categoryid'] catName = cat['Categoryname'] #log.error('Telewizjada: ' + catName) #categoryMap[str(catId)] = catName channelList = cat['Categorychannels'] for singleChannel in channelList: count += 1 channelId = singleChannel['id'] channelName = singleChannel['displayName'] #log.error('Telewizjada: ' + channelName) #if channelName in epgMapping: #channelName = epgMapping[channelName] channelThumb = singleChannel['thumb'] playlistManager.addChannel(count, channelName, channelThumb, catName, channelId) return playlistManager.getPlaylist()
def main(): # Remove old playlists active_playlists = find_playlists(config.DEST) for playlist_file in active_playlists: mtime = datetime.datetime.fromtimestamp(os.path.getmtime(os.path.join(config.DEST, playlist_file))) if mtime < datetime.datetime.now() - datetime.timedelta(days=6): os.unlink(os.path.join(config.DEST, playlist_file)) # Move new playlists into place playlists = find_playlists(config.STAGING) for playlist_file in playlists: p = playlist.playlist(os.path.join(config.STAGING, playlist_file)) if p.airdate < datetime.datetime.now(): # I should probably delete this continue if p.airdate > datetime.datetime.now() + datetime.timedelta(days=5.5): continue # p.airdate within 6 days from now if p.validate(): # Archive the playlist shutil.copyfile(p.filename, os.path.join(config.ARCHIVE, p.basename)) with open(os.path.join(config.DEST, p.translate_filename()), "w+") as f: p.translate(f) # Delete the old file os.unlink(os.path.join(p.filename)) # TODO: Trigger a reload of this playlist config.LIQUIDSOAP_SOCK update_playlist(p.translate_filename()) else: print("Playlist failed to validate") # Error handling goes here pass
def __init__(self): self.version = "1.3.1.1" self.platform = "linux" self.host = "ws.audioscrobbler.com" self.port = 80 self.info = None self.playlist = playlist.playlist() self.debug = 0
def __init__(self): self.version = "2.0" self.platform = "win32" self.platformversion = "Windows%20XP" self.player = "lastfmproxy-2.0" self.api_key = "d50ed5584be64a1564a5d1a12e3fef7f" self.host = "ws.audioscrobbler.com" self.port = 80 self.info = None self.playlist = playlist.playlist() self.debug = 0
def createPlaylist(self, channelsResp): #log.error('PierwszaTV: ' + str(channelsResp)) playlistManager = playlist.playlist() playlistManager.init('pierwszaTV') jsonChannels = json.loads(channelsResp) count = 0 for channel in jsonChannels['channels']: count += 1 channelName = channel['name'] channelId = channel['id'] channelThumb = channel['thumbail'] playlistManager.addChannel(count, channelName, channelThumb, 'All', channelId) return playlistManager.getPlaylist()
def main(): creds = None now = datetime.datetime.utcnow() oneHour = datetime.datetime.utcnow() + datetime.timedelta(hours=1) # If there are no (valid) credentials available, let the user log in. creds = auth(creds) vibes = playlist(creds) cal = build("calendar", "v3", credentials=creds) data = { "summary": "Yoga Time!", "location": "20 Gladstone Ave. Toronto Ontario M6J 3K6", "description": "Vibe out to some sweet sweet yoga, " + random.choice(vibes), "start": { "dateTime": now.isoformat("T") + "Z", "timeZone": "America/Toronto", }, "end": { "dateTime": oneHour.isoformat("T") + "Z", "timeZone": "America/Toronto", }, "recurrence": ["RRULE:FREQ=DAILY;COUNT=1"], "attendees": [ { "email": "*****@*****.**" }, ], "reminders": { "useDefault": False, "overrides": [ { "method": "email", "minutes": 24 * 60 }, { "method": "popup", "minutes": 10 }, ], }, } # Call the Calendar API event = cal.events().insert(calendarId="primary", body=data).execute() print("Event created: %s" % (event.get("htmlLink")))
def __init__(self): self.version = "1.5.4.24567" self.platform = "win32" self.platformversion = "Windows%20XP" self.player = "LastFMProxy" self.api_key = config.api_key self.api_secret = config.api_secret self.host = "ws.audioscrobbler.com" self.port = 80 self.info = None self.playlist = playlist.playlist() self.debug = 0 self.tmpResp = None self.sessionKey = None self.s = None
def __init__(self, screen, layout, channel, playerid): self.channel = channel self.keybindings = config.keybindings.playlistwindow self.songformat = config.playlistwindow.songformat h, w, y, x, border = layout window.window.__init__(self, screen, h, w, y, x, config.colors.playlistwindow, _("Playlist"), border, config.playlistwindow.scrollbar) # Immediately remove focus from playlist window in order to # prevent wrong selectionchanged events being issued, which # would lead to playing the first song in the playlist on the # second player (if configured) self.bottom() self.playlist = playlist.playlist(self, playerid) self.channel.subscribe(events.keypressed, self.keypressed) self.channel.subscribe(events.mouseevent, self.mouseevent) self.channel.subscribe(events.focuschanged, self.focuschanged)
def __init__(self): self.mainloop = GObject.MainLoop() import loggy loggy.debug_setting = True loggy.sb = self import config self.config = config.config(self) import sbdb self.sbdb = sbdb.sbdb(self) import player self.player = player.player(self) import playlist self.playlist = playlist.playlist(self) import mediakeys self.mediakeys = mediakeys.mediakeys(self) import debug debug.soundblizzard = self import mpdserver self.mpdserver = mpdserver.mpdserver(self) self.mpdserver.startserver('localhost', 6601) #import dbus_mpris #self.dbus_mpris = dbus_mpris.dbus_mpris(self) import gui self.gtkgui = gui.GTKGui(self)
def createPlaylist(self, channelsResp): playlistManager = playlist.playlist("pierwszaTV") channels = self.getChannelList(channelsResp) return playlistManager.getPlaylist(channels)
"c. View song library\n" "d. Play a song\n" "e. Play a playlist\n" "f. Quit") loop = 1 arg = 0 while loop == 1: menu() arg = input() if arg == 'a': titl = input("Playlist title: ") np = playlist(titl) library.playlists.append(np) with open('library.py', 'a') as f: f.write('\n' + titl + '=playlist("' + titl + '")') f.write('\nplaylists.append(' + titl + ')') print("Playlist added!") elif arg == 'b': option = 'a' while option != 'b': print("Which playlist?") print("Library: ") for pl in library.playlists: print(pl.title) playlist = input() st = input("Song title: ")
import record import songs import lyric import time from tqdm import tqdm # from retrying import retry import random if __name__ == '__main__': # -------record--------------------- url_record = 'https://music.163.com/weapi/v1/play/record?csrf_token=' all_list, week_list, all_name, week_name = record.record(url_record) # ---------------------------------- # print(all_list) lyric.lyric(all_list, all_name) lyric.lyric(week_list, week_name) # -------playlist------------------- url_playlist = 'https://music.163.com/weapi/user/playlist?csrf_token=' # 返回两个列表 idlist, namelist = playlist.playlist(url_playlist) # ---------------------------------- browser = songs.chromedriver() # -------songs---------------------- pbar = tqdm(idlist) for i, id in enumerate(pbar): pbar.set_description("Processing Topic:%s..." % namelist[i]) # i = i + 1 songs.songs(browser, id) time.sleep(random.randint(0, 2)) # ----------------------------------