Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram #72

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
22a2b11
improved by selery
artyshko Feb 15, 2019
f30672c
changed Procfile
artyshko Feb 15, 2019
a9d27bc
Heroku fix
artyshko Feb 15, 2019
a1fe54e
Heroku fix
artyshko Feb 15, 2019
48c6749
fixed heroku redis bug
artyshko Feb 16, 2019
4dc0d1f
added bash script
artyshko Feb 16, 2019
34bdb3e
fixed the mp3 names
artyshko Feb 24, 2019
1e48c7b
fixed telegram error "413 Request Entity Too Large"
artyshko Feb 24, 2019
3e795cc
Merge branch 'telegram-alpha' into telegram-beta
artyshko Feb 24, 2019
e57aa01
added new features from -alpha branch
artyshko Feb 24, 2019
d9ec6a5
updated limit
artyshko Feb 24, 2019
4afcf14
updated limit
artyshko Feb 24, 2019
d55a04b
fixed run out of memory error
artyshko Feb 24, 2019
681d69d
fix
artyshko Feb 24, 2019
b96440a
hotfix
artyshko Feb 24, 2019
43ab997
fix
artyshko Feb 24, 2019
18f63ca
fix
artyshko Feb 24, 2019
97a9381
hotfix
artyshko Feb 24, 2019
e33e27b
changed api key
artyshko Feb 24, 2019
a6ed225
added albums support
artyshko Mar 1, 2019
ab22618
added status
artyshko Mar 1, 2019
5874006
fixed image
artyshko Mar 3, 2019
ede692d
Update README.md
artyshko Mar 8, 2019
219f379
removed tokens
artyshko Mar 8, 2019
fe52fb9
Merge branch 'telegram-alpha' of https://github.com/artyshko/smd into…
artyshko Mar 8, 2019
697dfb9
Merge branch 'telegram-beta' into telegram
artyshko Mar 8, 2019
e7d3715
new hello message
artyshko Mar 9, 2019
1e2fdb3
Merge branch 'telegram' into telegram-alpha
artyshko Mar 15, 2019
8241006
fix
artyshko Mar 16, 2019
a6ec6f1
changed data
artyshko Mar 16, 2019
e02c4fb
optimized
artyshko Mar 16, 2019
f7d9325
hotfix
artyshko Mar 16, 2019
f1b1a4c
added Deezer support
artyshko Mar 16, 2019
50a61c4
Update README.md
artyshko Mar 17, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added .spotify
Binary file not shown.
Binary file added .telegram
Binary file not shown.
Binary file added Data/9.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Data/header1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
worker: python3 telegram.py
worker: bash worker.sh
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
# Spotify Music Downloader | **<a href="https://telegram.me/SpotifyMusicDownloaderBot"><b>Get it on Telegram</b></a>**
# Spotify Music Downloader Bot | **<a href="https://telegram.me/SpotifyMusicDownloaderBot"><b>Get it on Telegram</b></a>**

[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/) [![Open Source Love svg1](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/ellerbrock/open-source-badges/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

<img align="center" src="https://raw.githubusercontent.com/artyshko/smd/telegram-unstable/Data/header1.png">
<img align="center" src="https://raw.githubusercontent.com/artyshko/smd/telegram-unstable/Data/header2.png">
<img align="center" src="https://raw.githubusercontent.com/artyshko/smd/telegram-unstable/Data/header3.png">
<img align="center" src="https://raw.githubusercontent.com/artyshko/smd/telegram-unstable/Data/header5.png">
<img align="center" src="https://raw.githubusercontent.com/artyshko/smd/telegram-unstable/Data/header4.png">
<img align="center" src="https://telegra.ph/file/9aa2dbe8755ec9a1d256a.png">
<img align="center" src="https://telegra.ph/file/8e8a3a500eaf1d491dbd6.png">
<img align="center" src="https://telegra.ph/file/ea696ddba7754a7d69cef.png">
<img align="center" src="https://telegra.ph/file/c0c3ffbff02a90094bce5.png">
<img align="center" src="https://telegra.ph/file/96f4b501a429619888cb3.png">
<img align="center" src="https://telegra.ph/file/35c9427fbe65045b765ed.png">
<img align="center" src="https://telegra.ph/file/f2bade546c719a9c3fc1c.png">
<img align="center" src="https://telegra.ph/file/38e841982cb6392f12697.png">
<img align="center" src="https://telegra.ph/file/649ee11b4db6d2a5a21fa.png">
<img align="center" src="https://telegra.ph/file/3b2d3eef17ba9e6c2a6bc.png">
<img align="center" src="https://telegra.ph/file/073d93deef71e3e93e528.png">
<img align="center" src="https://telegra.ph/file/4f284eaa2413a47994124.png">
<img align="center" src="https://telegra.ph/file/14aed6c4e2ca89dbd4a41.png">
2 changes: 1 addition & 1 deletion apple.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get(self, url):

url = url + '&l=uk'


splitted = str(url).split('/')
splitted = splitted[:3]+['ua']+splitted[4:]
url = '/'.join(splitted)
Expand Down
73 changes: 73 additions & 0 deletions deezer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import requests

class Deezer(object):

def __init__(self):

'''
Init function
Creating deezer object
:return: None
'''

self.__url = 'http://api.deezer.com/'


def getSongInfo(self, id):

try:

response = requests.get(f'{self.__url}/track/{id}').json()

return ({
'uri' : f"D{response['id']}T",
'name' : response['title'],
'artist' : [response['artist']['name']],
'album' : response['album']['title'],
'image' : response['album']['cover_xl'],
'duration_ms' : response['duration']
})

except: return None

def getAlbum(self, id):

try:

response = requests.get(f'{self.__url}/album/{id}').json()

alb = {
'name':response['title'],
'artist':response['artist']['name'],
'copyright': None,
'image':response['cover_xl'],
}

tracks = []

for item in response['tracks']['data']:

tracks.append({
'uri' : f"D{item['id']}T",
'name' : item['title'],
'artist' : [item['artist']['name']],
'album' : alb['name'],
'image' : alb['image'],
'preview_url' : item['preview'],
'duration_ms' : item['duration']
})

alb.setdefault(
'tracks', tracks
)

return alb

except: return None

if __name__ == '__main__':

deezer = Deezer()
data = deezer.getSongInfo('636758392')

print(data)
66 changes: 66 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from youtube import Youtube
from editor import TagEditor
from lastfm import LastFM
from deezer import Deezer
import sys, getopt, shutil
import os

Expand All @@ -22,6 +23,7 @@ def __init__(self):
self.__spotify = Spotify()
self.__editor = TagEditor()
self.__last = LastFM()
self.__deezer = Deezer()


def __downloadMusicFromYoutube(self, name, uri, dur):
Expand Down Expand Up @@ -59,6 +61,9 @@ def getData(self, uri):
def getLastFMTags(self, name):
return self.__last.get(name)

def getDeezerTags(self, id):
return self.__deezer.getSongInfo(id)

def getYoutubeMusicInfo(self, url):
return self.__youtube.getNameFromYoutube(url)

Expand Down Expand Up @@ -302,9 +307,70 @@ def downloadFromYoutubeMusic(self, url, info):
else:
return False, None

def downloadByDeezerID(self, uri):
#get info
info = self.__deezer.getSongInfo(uri)

if info:

fixed_name = f'{info["artist"][0]} - {info["name"]}'
fixed_name = fixed_name.replace('.','')
fixed_name = fixed_name.replace(',','')
fixed_name = fixed_name.replace("'",'')
fixed_name = fixed_name.replace("/","")

#finding and download from YouTube and tagging
if self.__downloadMusicFromYoutube(fixed_name, info['uri'], info['duration_ms']):

self.__editor.setTags(
data=info
)

cachepath = os.getcwd() + '/cache'
fullpath = os.getcwd() + '/Downloads'

#logging
logging.info(f'CACHEPATH {cachepath}')
logging.info(f'FULLPATH {fullpath}')

if not os.path.exists(fullpath):
os.makedirs(fullpath)

os.rename(
f"{cachepath}/{info['uri']}/{info['uri']}.png",
f"{fullpath}/{info['uri']}.png"
)
#logging
logging.info(f"MOVE TO Downloads/{info['uri']}.png")

os.rename(
f"{cachepath}/{info['uri']}/{info['uri']}.mp3",
f"{fullpath}/{info['uri']}.mp3"
)
#logging
logging.info(f"MOVE TO Downloads/{info['uri']}.mp3")

#deleting cache
try:
shutil.rmtree(f"cache/{info['uri']}")
#logging
logging.info(f"DELETED cache/{info['uri']}")
except:
#logging
logging.error(f"DELETING cache/{info['uri']}")

return True
return False

def search(self, query):
return self.__spotify.search(query=query)

def getAlbum(self, uri):
return self.__spotify.getAlbum(uri)

def getAlbumDeezer(self, id):
return self.__deezer.getAlbum(id)



class CLI(object):
Expand Down
16 changes: 9 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
mutagen==1.41.0
lxml==4.2.3
Flask==0.12.2
moviepy==0.2.3.5
requests==2.18.4
spotipy==2.4.4
git+git://github.com/nficano/pytube.git
redis==2.10.6
imageio==2.3.0
git+git://github.com/nficano/pytube.git
spotipy==2.4.4
pyperclip==1.6.4
requests==2.18.4
moviepy==0.2.3.5
lxml==4.2.3
mutagen==1.41.0
Flask==0.12.2
celery==4.2.1
beautifulsoup4==4.7.1