Skip to content

Commit 414fcea

Browse files
committed
removed second Telegram session
1 parent 08a4926 commit 414fcea

File tree

4 files changed

+26
-28
lines changed

4 files changed

+26
-28
lines changed

README.md

+7-12
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Setup
2222
To sync your Spotify playlist with your Telegram channel you will need:
2323

2424
- **Spotify**: client ID, client secret, refresh token
25-
- **Telegram**: channel username, API ID, API hash, two string
26-
sessions
25+
- **Telegram**: channel username, API ID, API hash and a string session
2726
- **Deezer**: ARL token
2827
- **Database**: a table named *playlist* with two columns:
2928
*spotify\_id*, *telegram\_id*
@@ -59,12 +58,11 @@ from the command line:
5958

6059
Go to [my.telegram.org](https://my.telegram.org/). After logging in, go
6160
to *API development tools*, and create an app. After creating the app,
62-
copy *App api\_id* and *App api\_hash*. Next up is getting those two
63-
Telegram sessions.
61+
copy *App api\_id* and *App api\_hash*. Next up is getting a Telegram
62+
account session in string format.
6463

65-
Now run `string_session.py` in the `setup` folder twice to get two
66-
string sessions (one for the web process, and one for the worker
67-
process). You can run the script from the command line:
64+
Now run `string_session.py` in the `setup` folder to get the
65+
string session. You can run the script from the command line:
6866

6967
python string_session.py
7068

@@ -225,11 +223,8 @@ bot work:
225223
- **TELETHON\_API\_HASH**
226224
The API Hash of your Telegram app
227225

228-
- **TELETHON\_SESSION\_WORKER**
229-
The first session string of your Telegram account
230-
231-
- **TELETHON\_SESSION\_WEB**
232-
The second session string of your Telegram account
226+
- **TELEGRAM\_SESSION**
227+
The string session you generated using string_session.py
233228

234229
- **TELEGRAM\_CHANNEL**
235230
The username of your Telegram channel

app.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,8 @@
3636
"description": "Your Telegram app's API hash",
3737
"required": true
3838
},
39-
"TELETHON_SESSION_WORKER": {
40-
"description": "Your first session string of your Telegram account",
41-
"required": true
42-
},
43-
"TELETHON_SESSION_WEB": {
44-
"description": "Your second session string of your Telegram account",
39+
"TELEGRAM_SESSION": {
40+
"description": "The string session you generated using string_session.py",
4541
"required": true
4642
},
4743
"TELEGRAM_CHANNEL": {

spotify_telegram_sync/bot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ async def check_playlist():
418418

419419
async def keep_alive():
420420
"""Keep Heroku app from going to sleep
421-
by sending HTTP requests to web server
421+
by sending GET requests to the web server
422422
423423
"""
424424
while True:

spotify_telegram_sync/server.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
from constants import (SERVER_PORT, TELEGRAM_CHANNEL,
2-
SPOTIFY_PLAYLIST_ID, TELETHON_API_ID,
3-
TELETHON_API_HASH, TELETHON_SESSION_WEB,
4-
USING_WEB_SERVER, spotify)
1+
from constants import (SERVER_PORT,
2+
USING_WEB_SERVER)
3+
# from constants import (TELETHON_API_ID,
4+
# TELETHON_API_HASH,
5+
# TELETHON_SESSION_WEB,
6+
# spotify,
7+
# TELEGRAM_CHANNEL)
58
from get_song_file import download_track
69
from database import database
7-
810
from waitress import serve
9-
from telethon import TelegramClient
10-
from telethon.sessions import StringSession
11+
# from telethon import TelegramClient
12+
# from telethon.sessions import StringSession
1113
from flask import Flask, request
1214

1315
from threading import Thread
@@ -20,14 +22,19 @@
2022
playback = {'artist': '', 'title': '', 'time': time()}
2123

2224
# telegram client
23-
client = TelegramClient(StringSession(TELETHON_SESSION_WEB),
24-
TELETHON_API_ID, TELETHON_API_HASH)
25+
# client = TelegramClient(StringSession(TELEGRAM_SESSION_TWO),
26+
# TELETHON_API_ID, TELETHON_API_HASH)
2527

2628
# disable hachoir warnings
2729
logging.getLogger("hachoir").setLevel(logging.CRITICAL)
2830

2931

3032
def check_playlist():
33+
# You could have the playlist checked by
34+
# sending requests to the web server at example.com/check_playlist
35+
# but that would require another Telegram string session.
36+
return
37+
3138
# get id, url and isrc of non-local songs
3239
spotify_songs = []
3340
tracks = spotify.playlist_items(SPOTIFY_PLAYLIST_ID)

0 commit comments

Comments
 (0)