Example #1
0
def getsongs( tds ):

	downlist = ''
	cur = 1

	for i in tds:
		link = i['href']
		if not ismp3(link):
			continue
		# download song
		response = urlopen(link)
		songdata = response.read()
		songsoup = BeautifulSoup(songdata, 'lxml')
		links = songsoup.body.find_all('a')
		for dlink in links:
			if not ismp3(dlink['href']):
				continue
			print('Downloading song #' + str(cur))
			if genlist:
				downlist += dlink['href'] + '\n'
			else:
				subprocess.call(cmd_downloader + ' ' + dlink['href'])
			break # ehh

		cur += 1

	if genlist:
		open('list.txt', 'w').write(downlist)
Example #2
0
def getsongs(tds):

    downlist = ''
    cur = 1

    for i in tds:
        link = i['href']
        if not ismp3(link):
            continue
        # download song
        response = urlopen(link)
        songdata = response.read()
        songsoup = BeautifulSoup(songdata, 'lxml')
        links = songsoup.body.find_all('a')
        for dlink in links:
            if not ismp3(dlink['href']):
                continue
            print('Downloading song #' + str(cur))
            if genlist:
                downlist += dlink['href'] + '\n'
            else:
                subprocess.call(cmd_downloader + ' ' + dlink['href'])
            break  # ehh

        cur += 1

    if genlist:
        open('list.txt', 'w').write(downlist)
Example #3
0
	def download(self, **kwargs):
		'''
		Starts the video download in the specified format
		'''
		o = self.getBestDL(kwargs['res'], kwargs['bitrate'], kwargs['vext'], kwargs['aext'])
		if len(o) == 1:
			if o[0] == 0:
				pstr = 'youtube-dl'
			else:
				pstr = 'youtube-dl -f ' + str(o[0])
		else:
			if o[0] == 0:
				o[0] = 'bestvideo'
			if o[1] == 0:
				o[1] = 'bestaudio'
			pstr = 'youtube-dl -f ' + str(o[0]) + '+' + str(o[1])
			if o[0] == 0 and o[1] == 0:
				pstr = 'youtube-dl' # make it back in case both 0

		mconfigs = ''
		oext = kwargs['oext']
		if oext:
			mconfigs = ' ' + '--merge-output-format ' + oext
			mconfigs += ' ' + '--recode-video ' + oext
		if kwargs['more']:
			mconfigs += ' ' + kwargs['more']

		retcode = subprocess.call(pstr
			+ ' '
			+ self.url
			+ mconfigs
		)
		return retcode



# ydl = youtube_dl.YoutubeDL()
# url = 'https://www.youtube.com/watch?v=InF16sp7J0M'
# res = ydl.extract_info(url, download=False)
# ptr = open('video.json', 'r')
# res = json.loads(ptr.read())
# ptr.close()


# obj = res
# res = json.dumps(res, indent=4)
# # print(res)
# ptr = open('video.json', 'w')
# ptr.write(res)
# ptr.close()

# vc = Video(obj)

# print( vc.getVStream(720) )
# print( vc.getAStream(128))
# print( vc.getBestDL(480) )
Example #4
0
    def download(self, **kwargs):
        '''
		Starts the video download in the specified format
		'''
        o = self.getBestDL(kwargs['res'], kwargs['bitrate'], kwargs['vext'],
                           kwargs['aext'])
        if len(o) == 1:
            if o[0] == 0:
                pstr = 'youtube-dl'
            else:
                pstr = 'youtube-dl -f ' + str(o[0])
        else:
            if o[0] == 0:
                o[0] = 'bestvideo'
            if o[1] == 0:
                o[1] = 'bestaudio'
            pstr = 'youtube-dl -f ' + str(o[0]) + '+' + str(o[1])
            if o[0] == 0 and o[1] == 0:
                pstr = 'youtube-dl'  # make it back in case both 0

        mconfigs = ''
        oext = kwargs['oext']
        if oext:
            mconfigs = ' ' + '--merge-output-format ' + oext
            mconfigs += ' ' + '--recode-video ' + oext
        if kwargs['more']:
            mconfigs += ' ' + kwargs['more']

        retcode = subprocess.call(pstr + ' ' + self.url + mconfigs)
        return retcode


# ydl = youtube_dl.YoutubeDL()
# url = 'https://www.youtube.com/watch?v=InF16sp7J0M'
# res = ydl.extract_info(url, download=False)
# ptr = open('video.json', 'r')
# res = json.loads(ptr.read())
# ptr.close()

# obj = res
# res = json.dumps(res, indent=4)
# # print(res)
# ptr = open('video.json', 'w')
# ptr.write(res)
# ptr.close()

# vc = Video(obj)

# print( vc.getVStream(720) )
# print( vc.getAStream(128))
# print( vc.getBestDL(480) )
Example #5
0
    reduced = ""
    if ti.find(video_identifier) != -1:
        reduced = ti.replace(video_identifier, "")
    if ti.find(audio_identifier) != -1:
        reduced = ti.replace(audio_identifier, "")
    if reduced == "":  # if different file
        continue
    if not reduced in dic:
        dic[reduced] = []
    dic[reduced].append(i)

# got the pairs, now merge them

for i in dic:
    if len(dic[i]) == 2:
        subprocess.call(
            ["ffmpeg", "-i", dic[i][0], "-i", dic[i][1], "-c:v", "copy", "-c:a", "copy", i.strip() + "." + output_ext],
            cwd=path,
        )

# done
# now delete source files

confirm = input("Delete source files (y/n) ?\n> ").lower()

if confirm == "y":
    for i in dic:
        if len(dic[i]) == 2:
            os.remove(path + "/" + dic[i][0])
            os.remove(path + "/" + dic[i][1])
Example #6
0
    if ti.find(video_identifier) != -1:
        reduced = ti.replace(video_identifier, '')
    if ti.find(audio_identifier) != -1:
        reduced = ti.replace(audio_identifier, '')
    if reduced == '':  # if different file
        continue
    if not reduced in dic:
        dic[reduced] = []
    dic[reduced].append(i)

# got the pairs, now merge them

for i in dic:
    if len(dic[i]) == 2:
        subprocess.call([
            'ffmpeg', '-i', dic[i][0], '-i', dic[i][1], '-c:v', 'copy', '-c:a',
            'copy',
            i.strip() + '.' + output_ext
        ],
                        cwd=path)

# done
# now delete source files

confirm = input('Delete source files (y/n) ?\n> ').lower()

if confirm == 'y':
    for i in dic:
        if len(dic[i]) == 2:
            os.remove(path + '/' + dic[i][0])
            os.remove(path + '/' + dic[i][1])