Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-gTTS for openSUSE:Factory 
checked in at 2021-02-09 21:17:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-gTTS (Old)
 and      /work/SRC/openSUSE:Factory/.python-gTTS.new.28504 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-gTTS"

Tue Feb  9 21:17:35 2021 rev:7 rq:870610 version:2.2.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-gTTS/python-gTTS.changes  2020-05-28 
09:16:43.992880745 +0200
+++ /work/SRC/openSUSE:Factory/.python-gTTS.new.28504/python-gTTS.changes       
2021-02-09 21:17:37.466867589 +0100
@@ -1,0 +2,22 @@
+Tue Feb  9 07:00:03 UTC 2021 - Adrian Schr??ter <[email protected]>
+
+- update to 2.2.2
+  Features
+    Adds a language fallback feature for deprecated languages to
+    maintain compatiblity (e.g. en-us becomes en). Fallback can be
+    disabled with lang_check=False or --nocheck for the cli (#267)
+  Bugfixes
+    Fix Python 2.7 compatiblity (!). Python 2 is long gone, but the
+    cut wasn't clearly communicated for gTTS, so it was restored.
+    Python 2 support will be completely removed in the next major
+    release. (#255)
+    Language code case sensitivity is maintained throughout (#267)
+  Deprecations and Removals
+    The following list of 'hyphenated' language codes no longer
+    work and have been removed: en-us, en-ca, en-uk, en-gb, en-au,
+    en-gh, en-in, en-ie, en-nz, en-ng, en-ph, en-za, en-tz, fr-ca
+    fr-fr, pt-br, pt-pt, es-es, es-us, zh-cn, zh-tw (#267)
+    Removed the gtts.get_url() method (outdated since 2.1.0) (#270)
+- Drop remove-pip-requirement.patch
+
+-------------------------------------------------------------------

Old:
----
  gTTS-2.1.1.tar.gz
  remove-pip-requirement.patch

New:
----
  gTTS-2.2.2.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-gTTS.spec ++++++
--- /var/tmp/diff_new_pack.nJqPOY/_old  2021-02-09 21:17:38.082868314 +0100
+++ /var/tmp/diff_new_pack.nJqPOY/_new  2021-02-09 21:17:38.086868320 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-gTTS
 #
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2021 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,14 +18,13 @@
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 Name:           python-gTTS
-Version:        2.1.1
+Version:        2.2.2
 Release:        0
 Summary:        Python module to create MP3 files from spoken text via the 
Google TTS API
 License:        MIT
 Group:          Development/Languages/Python
 URL:            https://github.com/pndurette/gTTS
 Source:         
https://files.pythonhosted.org/packages/source/g/gTTS/gTTS-%{version}.tar.gz
-Patch0:         remove-pip-requirement.patch
 BuildRequires:  %{python_module beautifulsoup4}
 BuildRequires:  %{python_module click}
 BuildRequires:  %{python_module gTTS-token >= 1.1.3}
@@ -56,7 +55,6 @@
 
 %prep
 %setup -q -n gTTS-%{version}
-%patch0 -p1
 
 %build
 %python_build

++++++ gTTS-2.1.1.tar.gz -> gTTS-2.2.2.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/CHANGELOG.rst new/gTTS-2.2.2/CHANGELOG.rst
--- old/gTTS-2.1.1/CHANGELOG.rst        2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/CHANGELOG.rst        2021-02-04 05:09:27.000000000 +0100
@@ -9,6 +9,100 @@
 
 .. towncrier release notes start
 
+2.2.2 (2021-02-03)
+------------------
+
+Features
+~~~~~~~~
+
+- Adds a language fallback feature for deprecated languages to maintain 
compatiblity  (e.g. ``en-us`` becomes ``en``). Fallback can be disabled with 
``lang_check=False`` or ``--nocheck`` for the cli (`#267 
<https://github.com/pndurette/gTTS/issues/267>`_)
+
+
+Bugfixes
+~~~~~~~~
+
+- Fix Python 2.7 compatiblity (!). Python 2 is long gone, but the cut wasn't 
clearly communicated for gTTS, so it was restored. Python 2 support will be 
completely removed in the next major release. (`#255 
<https://github.com/pndurette/gTTS/issues/255>`_)
+- Language code case sensitivity is maintained throughout (`#267 
<https://github.com/pndurette/gTTS/issues/267>`_)
+
+
+Deprecations and Removals
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+- The following list of 'hyphenated' language codes no longer work and have 
been removed: ``en-us``, ``en-ca``, ``en-uk``, ``en-gb``, ``en-au``, ``en-gh``, 
``en-in``, ``en-ie``, ``en-nz``, ``en-ng``, ``en-ph``, ``en-za``, ``en-tz``, 
``fr-ca``, ``fr-fr``, ``pt-br``, ``pt-pt``, ``es-es``, ``es-us``, ``zh-cn``, 
``zh-tw`` (`#267 <https://github.com/pndurette/gTTS/issues/267>`_)
+- Removed the ``gtts.get_url()`` method (outdated since ``2.1.0``) (`#270 
<https://github.com/pndurette/gTTS/issues/270>`_)
+
+
+2.2.1 (2020-11-15)
+------------------
+
+Bugfixes
+~~~~~~~~
+
+- ``_package_rpc()`` was erroneously packaging the entire text instead of 
tokenized part (`#252 <https://github.com/pndurette/gTTS/issues/252>`_)
+
+
+Improved Documentation
+~~~~~~~~~~~~~~~~~~~~~~
+
+- Removes reference to automatic retrieval of languages (`#250 
<https://github.com/pndurette/gTTS/issues/250>`_)
+
+
+Misc
+~~~~
+
+- `#251 <https://github.com/pndurette/gTTS/issues/251>`_
+
+
+2.2.0 (2020-11-14)
+------------------
+
+Features
+~~~~~~~~
+
+- Switch to the newer Google TTS API (thanks to `@Boudewijn26! 
<https://github.com/pndurette/gTTS/pull/244>`_). See `his great writeup 
<https://github.com/Boudewijn26/gTTS-token/blob/master/docs/november-2020-translate-changes.md>`_
 for more on the methodology and why this was necessary. (`#226 
<https://github.com/pndurette/gTTS/issues/226>`_, `#232 
<https://github.com/pndurette/gTTS/issues/232>`_, `#236 
<https://github.com/pndurette/gTTS/issues/236>`_, `#241 
<https://github.com/pndurette/gTTS/issues/241>`_)
+
+
+Deprecations and Removals
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+- Removed automatic language download from the main code, which has become too 
unreliable & slow.
+  Languages will still be fetched but a pre-generated list will be shipped 
with ``gTTS``. (`#233 <https://github.com/pndurette/gTTS/issues/233>`_, `#241 
<https://github.com/pndurette/gTTS/issues/241>`_, `#242 
<https://github.com/pndurette/gTTS/issues/242>`_, `#243 
<https://github.com/pndurette/gTTS/issues/243>`_)
+- Because languages are now pre-generated, removed custom TLD support for 
language URL (which allowed to get language **names** in other than English) 
(`#245 <https://github.com/pndurette/gTTS/issues/245>`_)
+
+
+Misc
+~~~~
+
+- `#245 <https://github.com/pndurette/gTTS/issues/245>`_
+
+
+2.1.2 (2020-11-10)
+------------------
+
+Features
+~~~~~~~~
+
+- Update `gTTS-token` to `1.1.4` (`#238 
<https://github.com/pndurette/gTTS/issues/238>`_)
+
+
+Bugfixes
+~~~~~~~~
+
+- Fixed an issue where some tokens could be empty after minimization (`#229 
<https://github.com/pndurette/gTTS/issues/229>`_, `#239 
<https://github.com/pndurette/gTTS/issues/239>`_)
+
+
+Improved Documentation
+~~~~~~~~~~~~~~~~~~~~~~
+
+- Grammar, spelling and example fixes (`#227 
<https://github.com/pndurette/gTTS/issues/227>`_)
+
+
+Misc
+~~~~
+
+- `#218 <https://github.com/pndurette/gTTS/issues/218>`_, `#230 
<https://github.com/pndurette/gTTS/issues/230>`_, `#231 
<https://github.com/pndurette/gTTS/issues/231>`_, `#239 
<https://github.com/pndurette/gTTS/issues/239>`_
+
+
 2.1.1 (2020-01-25)
 ------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/LICENSE new/gTTS-2.2.2/LICENSE
--- old/gTTS-2.1.1/LICENSE      2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/LICENSE      2021-02-04 05:09:27.000000000 +0100
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright ?? 2014-2020 Pierre Nicolas Durette
+Copyright ?? 2014-2021 Pierre Nicolas Durette
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/PKG-INFO new/gTTS-2.2.2/PKG-INFO
--- old/gTTS-2.1.1/PKG-INFO     2020-01-26 04:22:49.388464500 +0100
+++ new/gTTS-2.2.2/PKG-INFO     2021-02-04 05:10:00.684482000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: gTTS
-Version: 2.1.1
+Version: 2.2.2
 Summary: gTTS (Google Text-to-Speech), a Python library and CLI tool to 
interface with Google Translate text-to-speech API
 Home-page: https://github.com/pndurette/gTTS
 Author: Pierre Nicolas Durette
@@ -14,7 +14,7 @@
         
         [![PyPI 
version](https://img.shields.io/pypi/v/gTTS.svg)](https://pypi.org/project/gTTS/)
         [![Python 
versions](https://img.shields.io/pypi/pyversions/gTTS.svg)](https://pypi.org/project/gTTS/)
-        [![Push 
workflow](https://github.com/pndurette/gTTS/workflows/Push/badge.svg)](https://github.com/pndurette/gTTS/actions)
+        [![Tests 
workflow](https://github.com/pndurette/gTTS/workflows/Tests/badge.svg)](https://github.com/pndurette/gTTS/actions)
         
[![codecov](https://codecov.io/gh/pndurette/gTTS/branch/master/graph/badge.svg)](https://codecov.io/gh/pndurette/gTTS)
         [![Commits 
Since](https://img.shields.io/github/commits-since/pndurette/gTTS/latest.svg)](https://github.com/pndurette/gTTS/commits/)
         [![PyPi 
Downloads](http://pepy.tech/badge/gtts)](http://pepy.tech/project/gtts)
@@ -24,7 +24,6 @@
         
         -   Customizable speech-specific sentence tokenizer that allows for 
unlimited lengths of text to be read, all while keeping proper intonation, 
abbreviations, decimals and more;
         -   Customizable text pre-processors which can, for example, provide 
pronunciation corrections;
-        -   Automatic retrieval of supported languages.
         
         ### Installation
         
@@ -44,6 +43,10 @@
         
         See <http://gtts.readthedocs.org/> for documentation and examples.
         
+        ### Disclaimer
+        
+        This project is *not* affiliated with Google or Google Cloud. Breaking 
upstream changes *can* occur without notice. This project is leveraging the 
undocumented [Google Translate](https://translate.google.com) speech 
functionality and is *different* from [Google Cloud 
Text-to-Speech](https://cloud.google.com/text-to-speech/).
+        
         ### Project
         
         -   [Changelog](CHANGELOG.rst)
@@ -51,8 +54,7 @@
         
         ### Licence
         
-        [The MIT License (MIT)](LICENSE) Copyright ?? 2014-2020 Pierre Nicolas 
Durette
-        
+        [The MIT License (MIT)](LICENSE) Copyright ?? 2014-2021 Pierre Nicolas 
Durette & [Contributors](https://github.com/pndurette/gTTS/graphs/contributors)
 Keywords: gtts,text to speech,Google Translate,TTS
 Platform: UNKNOWN
 Classifier: Environment :: Console
@@ -64,10 +66,10 @@
 Classifier: Operating System :: POSIX :: Linux
 Classifier: Operating System :: Microsoft :: Windows
 Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: 3.7
 Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
 Classifier: Topic :: Software Development :: Libraries
 Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
 Requires-Python: >=2.7
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/README.md new/gTTS-2.2.2/README.md
--- old/gTTS-2.1.1/README.md    2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/README.md    2021-02-04 05:09:27.000000000 +0100
@@ -6,7 +6,7 @@
 
 [![PyPI 
version](https://img.shields.io/pypi/v/gTTS.svg)](https://pypi.org/project/gTTS/)
 [![Python 
versions](https://img.shields.io/pypi/pyversions/gTTS.svg)](https://pypi.org/project/gTTS/)
-[![Push 
workflow](https://github.com/pndurette/gTTS/workflows/Push/badge.svg)](https://github.com/pndurette/gTTS/actions)
+[![Tests 
workflow](https://github.com/pndurette/gTTS/workflows/Tests/badge.svg)](https://github.com/pndurette/gTTS/actions)
 
[![codecov](https://codecov.io/gh/pndurette/gTTS/branch/master/graph/badge.svg)](https://codecov.io/gh/pndurette/gTTS)
 [![Commits 
Since](https://img.shields.io/github/commits-since/pndurette/gTTS/latest.svg)](https://github.com/pndurette/gTTS/commits/)
 [![PyPi Downloads](http://pepy.tech/badge/gtts)](http://pepy.tech/project/gtts)
@@ -16,7 +16,6 @@
 
 -   Customizable speech-specific sentence tokenizer that allows for unlimited 
lengths of text to be read, all while keeping proper intonation, abbreviations, 
decimals and more;
 -   Customizable text pre-processors which can, for example, provide 
pronunciation corrections;
--   Automatic retrieval of supported languages.
 
 ### Installation
 
@@ -36,6 +35,10 @@
 
 See <http://gtts.readthedocs.org/> for documentation and examples.
 
+### Disclaimer
+
+This project is *not* affiliated with Google or Google Cloud. Breaking 
upstream changes *can* occur without notice. This project is leveraging the 
undocumented [Google Translate](https://translate.google.com) speech 
functionality and is *different* from [Google Cloud 
Text-to-Speech](https://cloud.google.com/text-to-speech/).
+
 ### Project
 
 -   [Changelog](CHANGELOG.rst)
@@ -43,4 +46,4 @@
 
 ### Licence
 
-[The MIT License (MIT)](LICENSE) Copyright ?? 2014-2020 Pierre Nicolas Durette
+[The MIT License (MIT)](LICENSE) Copyright ?? 2014-2021 Pierre Nicolas Durette 
& [Contributors](https://github.com/pndurette/gTTS/graphs/contributors)
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gTTS.egg-info/PKG-INFO 
new/gTTS-2.2.2/gTTS.egg-info/PKG-INFO
--- old/gTTS-2.1.1/gTTS.egg-info/PKG-INFO       2020-01-26 04:22:49.000000000 
+0100
+++ new/gTTS-2.2.2/gTTS.egg-info/PKG-INFO       2021-02-04 05:10:00.000000000 
+0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: gTTS
-Version: 2.1.1
+Version: 2.2.2
 Summary: gTTS (Google Text-to-Speech), a Python library and CLI tool to 
interface with Google Translate text-to-speech API
 Home-page: https://github.com/pndurette/gTTS
 Author: Pierre Nicolas Durette
@@ -14,7 +14,7 @@
         
         [![PyPI 
version](https://img.shields.io/pypi/v/gTTS.svg)](https://pypi.org/project/gTTS/)
         [![Python 
versions](https://img.shields.io/pypi/pyversions/gTTS.svg)](https://pypi.org/project/gTTS/)
-        [![Push 
workflow](https://github.com/pndurette/gTTS/workflows/Push/badge.svg)](https://github.com/pndurette/gTTS/actions)
+        [![Tests 
workflow](https://github.com/pndurette/gTTS/workflows/Tests/badge.svg)](https://github.com/pndurette/gTTS/actions)
         
[![codecov](https://codecov.io/gh/pndurette/gTTS/branch/master/graph/badge.svg)](https://codecov.io/gh/pndurette/gTTS)
         [![Commits 
Since](https://img.shields.io/github/commits-since/pndurette/gTTS/latest.svg)](https://github.com/pndurette/gTTS/commits/)
         [![PyPi 
Downloads](http://pepy.tech/badge/gtts)](http://pepy.tech/project/gtts)
@@ -24,7 +24,6 @@
         
         -   Customizable speech-specific sentence tokenizer that allows for 
unlimited lengths of text to be read, all while keeping proper intonation, 
abbreviations, decimals and more;
         -   Customizable text pre-processors which can, for example, provide 
pronunciation corrections;
-        -   Automatic retrieval of supported languages.
         
         ### Installation
         
@@ -44,6 +43,10 @@
         
         See <http://gtts.readthedocs.org/> for documentation and examples.
         
+        ### Disclaimer
+        
+        This project is *not* affiliated with Google or Google Cloud. Breaking 
upstream changes *can* occur without notice. This project is leveraging the 
undocumented [Google Translate](https://translate.google.com) speech 
functionality and is *different* from [Google Cloud 
Text-to-Speech](https://cloud.google.com/text-to-speech/).
+        
         ### Project
         
         -   [Changelog](CHANGELOG.rst)
@@ -51,8 +54,7 @@
         
         ### Licence
         
-        [The MIT License (MIT)](LICENSE) Copyright ?? 2014-2020 Pierre Nicolas 
Durette
-        
+        [The MIT License (MIT)](LICENSE) Copyright ?? 2014-2021 Pierre Nicolas 
Durette & [Contributors](https://github.com/pndurette/gTTS/graphs/contributors)
 Keywords: gtts,text to speech,Google Translate,TTS
 Platform: UNKNOWN
 Classifier: Environment :: Console
@@ -64,10 +66,10 @@
 Classifier: Operating System :: POSIX :: Linux
 Classifier: Operating System :: Microsoft :: Windows
 Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.5
 Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: 3.7
 Classifier: Programming Language :: Python :: 3.8
+Classifier: Programming Language :: Python :: 3.9
 Classifier: Topic :: Software Development :: Libraries
 Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
 Requires-Python: >=2.7
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gTTS.egg-info/SOURCES.txt 
new/gTTS-2.2.2/gTTS.egg-info/SOURCES.txt
--- old/gTTS-2.1.1/gTTS.egg-info/SOURCES.txt    2020-01-26 04:22:49.000000000 
+0100
+++ new/gTTS-2.2.2/gTTS.egg-info/SOURCES.txt    2021-02-04 05:10:00.000000000 
+0100
@@ -16,6 +16,7 @@
 gtts/__init__.py
 gtts/cli.py
 gtts/lang.py
+gtts/langs.py
 gtts/tts.py
 gtts/utils.py
 gtts/version.py
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gTTS.egg-info/requires.txt 
new/gTTS-2.2.2/gTTS.egg-info/requires.txt
--- old/gTTS-2.1.1/gTTS.egg-info/requires.txt   2020-01-26 04:22:49.000000000 
+0100
+++ new/gTTS-2.2.2/gTTS.egg-info/requires.txt   2021-02-04 05:10:00.000000000 
+0100
@@ -1,8 +1,6 @@
 six
-beautifulsoup4
 click
 requests
-gtts_token>=1.1.3
 
 [docs]
 sphinx
@@ -12,7 +10,7 @@
 towncrier
 
 [tests]
-pytest>=3.9
+pytest==4.6.11
 pytest-cov
 flake8
 testfixtures
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/cli.py new/gTTS-2.2.2/gtts/cli.py
--- old/gTTS-2.1.1/gtts/cli.py  2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/gtts/cli.py  2021-02-04 05:09:27.000000000 +0100
@@ -60,14 +60,12 @@
 def validate_lang(ctx, param, lang):
     """Validation callback for the <lang> option.
     Ensures <lang> is a supported language unless the <nocheck> flag is set
-    Uses <tld> to fetch languages from other domains
     """
     if ctx.params['nocheck']:
         return lang
 
     try:
-        tld = ctx.params['tld']
-        if lang not in tts_langs(tld):
+        if lang not in tts_langs():
             raise click.UsageError(
                 "'%s' not in list of supported languages.\n"
                 "Use --all to list languages or "
@@ -92,14 +90,7 @@
         return
 
     try:
-        tld = ctx.params['tld']
-    except KeyError:
-        # Either --tld was used after --all or not at all
-        # Default to the 'com' tld
-        tld = 'com'
-
-    try:
-        langs = tts_langs(tld)
+        langs = tts_langs()
         langs_str_list = sorted("{}: {}".format(k, langs[k]) for k in langs)
         click.echo('  ' + '\n  '.join(langs_str_list))
     except RuntimeError as e:  # pragma: no cover
@@ -167,8 +158,7 @@
     is_eager=True,
     expose_value=False,
     callback=print_languages,
-    help="Print all documented available IETF language tags and exit. "
-         "Use --tld beforehand to use an alternate domain")
+    help="Print all documented available IETF language tags and exit.")
 @click.option(
     '--debug',
     default=False,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/lang.py new/gTTS-2.2.2/gtts/lang.py
--- old/gTTS-2.1.1/gtts/lang.py 2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/gtts/lang.py 2021-02-04 05:09:27.000000000 +0100
@@ -1,9 +1,7 @@
 # -*- coding: utf-8 -*-
-from gtts.utils import _translate_url
-from bs4 import BeautifulSoup
-import requests
+from gtts.langs import _main_langs
+from warnings import warn
 import logging
-import re
 
 __all__ = ['tts_langs']
 
@@ -12,94 +10,28 @@
 log.addHandler(logging.NullHandler())
 
 
-def tts_langs(tld="com"):
+def tts_langs():
     """Languages Google Text-to-Speech supports.
 
-    Args:
-        tld (string): Top-level domain for the Google Translate host
-            to fetch languages from. i.e `https://translate.google.<tld>`.
-            Default is ``com``.
-
     Returns:
-        dict: A dictionnary of the type `{ '<lang>': '<name>'}`
+        dict: A dictionary of the type `{ '<lang>': '<name>'}`
 
-            Where `<lang>` is an IETF language tag such as `en` or `pt-br`,
+            Where `<lang>` is an IETF language tag such as `en` or `zh-TW`,
             and `<name>` is the full English name of the language, such as
-            `English` or `Portuguese (Brazil)`.
+            `English` or `Chinese (Mandarin/Taiwan)`.
 
-    The dictionnary returned combines languages from two origins:
+    The dictionary returned combines languages from two origins:
 
-    - Languages fetched automatically from Google Translate
+    - Languages fetched from Google Translate (pre-generated in 
:mod:`gtts.langs`)
     - Languages that are undocumented variations that were observed to work and
       present different dialects or accents.
 
     """
-    try:
-        langs = dict()
-        log.debug("Fetching with '{}' tld".format(tld))
-        langs.update(_fetch_langs(tld))
-        langs.update(_extra_langs())
-        log.debug("langs: {}".format(langs))
-        return langs
-    except Exception as e:
-        raise RuntimeError("Unable to get language list: {}".format(str(e)))
-
-
-def _fetch_langs(tld="com"):
-    """Fetch (scrape) languages from Google Translate.
-
-    Google Translate loads a JavaScript Array of 'languages codes' that can
-    be spoken. We intersect this list with all the languages Google Translate
-    provides to get the ones that support text-to-speech.
-
-    Args:
-        tld (string): Top-level domain for the Google Translate host
-            to fetch languages from. i.e `https://translate.google.<tld>`.
-            The language names obtained will be in a language locale of the TLD
-            (e.g. ``tld=fr`` will retrieve the French names of the languages).
-            Default is ``com``.
-
-    Returns:
-        dict: A dictionnary of languages from Google Translate
-
-    """
-    URL_BASE = _translate_url(tld)
-
-    # The JavaScript file to look for is either:
-    # * translate_m.js or
-    # * translate_m_<lang-code>.js
-    #   e.g. translate_m_fr.js or translate_m_zh-CN.js
-    JS_FILE = r'translate_m(|_\S*)\.js'
-
-    # Load HTML
-    page = requests.get(URL_BASE)
-    soup = BeautifulSoup(page.content, 'html.parser')
-
-    # JavaScript URL
-    # The <script src=''> path can change, but not the file.
-    # Ex: /zyx/abc/20180211/translate_m.js
-    js_path = soup.find(src=re.compile(JS_FILE))['src']
-    js_url = "{}/{}".format(URL_BASE, js_path)
-
-    # Load JavaScript
-    js_contents = requests.get(js_url).text
-
-    # Approximately extract TTS-enabled language codes
-    # RegEx pattern search because minified variables can change.
-    # Extra garbage will be dealt with later as we keep languages only.
-    # In: "[...]Fv={af:1,ar:1,[...],zh:1,"zh-cn":1,"zh-tw":1}[...]"
-    # Out: ['is', '12', [...], 'af', 'ar', [...], 'zh', 'zh-cn', 'zh-tw']
-    pattern = r'[{,\"](\w{2}|\w{2}-\w{2,3})(?=:1|\":1)'
-    tts_langs = re.findall(pattern, js_contents)
-
-    # Build lang. dict. from main page (JavaScript object populating lang. 
menu)
-    # Filtering with the TTS-enabled languages
-    # In: "{code:'auto',name:'Detect 
language'},{code:'af',name:'Afrikaans'},[...]"
-    # re.findall: [('auto', 'Detect language'), ('af', 'Afrikaans'), [...]]
-    # Out: {'af': 'Afrikaans', [...]}
-    trans_pattern = r"{code:'(?P<lang>.+?[^'])',name:'(?P<name>.+?[^'])'}"
-    trans_langs = re.findall(trans_pattern, page.text)
-    return {lang: name for lang, name in trans_langs if lang in tts_langs}
+    langs = dict()
+    langs.update(_main_langs())
+    langs.update(_extra_langs())
+    log.debug("langs: {}".format(langs))
+    return langs
 
 
 def _extra_langs():
@@ -108,36 +40,59 @@
     Returns:
         dict: A dictionnary of extra languages manually defined.
 
-            Variations of the ones fetched by `_fetch_langs`,
+            Variations of the ones generated in `_main_langs`,
             observed to provide different dialects or accents or
             just simply accepted by the Google Translate Text-to-Speech API.
 
     """
     return {
         # Chinese
-        'zh-cn': 'Chinese (Mandarin/China)',
-        'zh-tw': 'Chinese (Mandarin/Taiwan)',
-        # English
-        'en-us': 'English (US)',
-        'en-ca': 'English (Canada)',
-        'en-uk': 'English (UK)',
-        'en-gb': 'English (UK)',
-        'en-au': 'English (Australia)',
-        'en-gh': 'English (Ghana)',
-        'en-in': 'English (India)',
-        'en-ie': 'English (Ireland)',
-        'en-nz': 'English (New Zealand)',
-        'en-ng': 'English (Nigeria)',
-        'en-ph': 'English (Philippines)',
-        'en-za': 'English (South Africa)',
-        'en-tz': 'English (Tanzania)',
-        # French
-        'fr-ca': 'French (Canada)',
-        'fr-fr': 'French (France)',
-        # Portuguese
-        'pt-br': 'Portuguese (Brazil)',
-        'pt-pt': 'Portuguese (Portugal)',
-        # Spanish
-        'es-es': 'Spanish (Spain)',
-        'es-us': 'Spanish (United States)'
+        'zh-TW': 'Chinese (Mandarin/Taiwan)',
+        'zh': 'Chinese (Mandarin)'
     }
+
+
+def _fallback_deprecated_lang(lang):
+    """Languages Google Text-to-Speech used to support.
+
+    Language tags that don't work anymore, but that can
+    fallback to a more general language code to maintain
+    compatibility.
+
+    Args:
+        lang (string): The language tag.
+
+    Returns:
+        string: The language tag, as-is if not deprecated,
+            or a fallack if it exits.
+
+    Example:
+        ``en-GB`` returns ``en``.
+        ``en-gb`` returns ``en``.
+
+    """
+
+    deprecated = {
+        # '<fallback>': [<list of deprecated langs>]
+        'en': ['en-us', 'en-ca', 'en-uk', 'en-gb', 'en-au', 'en-gh', 'en-in',
+               'en-ie', 'en-nz', 'en-ng', 'en-ph', 'en-za', 'en-tz'],
+        'fr': ['fr-ca', 'fr-fr'],
+        'pt': ['pt-br', 'pt-pt'],
+        'es': ['es-es', 'es-us'],
+        'zh-CN': ['zh-cn'],
+        'zh-TW': ['zh-tw'],
+    }
+
+    for fallback_lang, deprecated_langs in deprecated.items():
+        if lang.lower() in deprecated_langs:
+            msg = (
+                "'{}' has been deprecated, falling back to '{}'. "
+                "This fallback will be removed in a future version."
+            ).format(lang, fallback_lang)
+
+            warn(msg, DeprecationWarning)
+            log.warning(msg)
+
+            return fallback_lang
+
+    return lang
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/langs.py new/gTTS-2.2.2/gtts/langs.py
--- old/gTTS-2.1.1/gtts/langs.py        1970-01-01 01:00:00.000000000 +0100
+++ new/gTTS-2.2.2/gtts/langs.py        2021-02-04 05:09:27.000000000 +0100
@@ -0,0 +1,64 @@
+# Note: this file is generated
+_langs = {
+    "af": "Afrikaans",
+    "ar": "Arabic",
+    "bn": "Bengali",
+    "bs": "Bosnian",
+    "ca": "Catalan",
+    "cs": "Czech",
+    "cy": "Welsh",
+    "da": "Danish",
+    "de": "German",
+    "el": "Greek",
+    "en": "English",
+    "eo": "Esperanto",
+    "es": "Spanish",
+    "et": "Estonian",
+    "fi": "Finnish",
+    "fr": "French",
+    "gu": "Gujarati",
+    "hi": "Hindi",
+    "hr": "Croatian",
+    "hu": "Hungarian",
+    "hy": "Armenian",
+    "id": "Indonesian",
+    "is": "Icelandic",
+    "it": "Italian",
+    "ja": "Japanese",
+    "jw": "Javanese",
+    "km": "Khmer",
+    "kn": "Kannada",
+    "ko": "Korean",
+    "la": "Latin",
+    "lv": "Latvian",
+    "mk": "Macedonian",
+    "ml": "Malayalam",
+    "mr": "Marathi",
+    "my": "Myanmar (Burmese)",
+    "ne": "Nepali",
+    "nl": "Dutch",
+    "no": "Norwegian",
+    "pl": "Polish",
+    "pt": "Portuguese",
+    "ro": "Romanian",
+    "ru": "Russian",
+    "si": "Sinhala",
+    "sk": "Slovak",
+    "sq": "Albanian",
+    "sr": "Serbian",
+    "su": "Sundanese",
+    "sv": "Swedish",
+    "sw": "Swahili",
+    "ta": "Tamil",
+    "te": "Telugu",
+    "th": "Thai",
+    "tl": "Filipino",
+    "tr": "Turkish",
+    "uk": "Ukrainian",
+    "ur": "Urdu",
+    "vi": "Vietnamese",
+    "zh-CN": "Chinese"
+}
+
+def _main_langs():
+    return _langs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/tests/test_cli.py 
new/gTTS-2.2.2/gtts/tests/test_cli.py
--- old/gTTS-2.1.1/gtts/tests/test_cli.py       2020-01-26 04:22:29.000000000 
+0100
+++ new/gTTS-2.2.2/gtts/tests/test_cli.py       2021-02-04 05:09:27.000000000 
+0100
@@ -66,6 +66,7 @@
 
 
 # <all> tests
[email protected]
 def test_all():
     """Option <all> should return a list of languages"""
     result = runner(['--all'])
@@ -77,17 +78,8 @@
     assert result.exit_code == 0
 
 
-def test_all_tld():
-    """Option <all> should return a list of languages"""
-    result = runner(['--tld', 'it', '--all'])
-
-    # Top-level domain set to 'it', language outputs should be Italian
-
-    assert "en: Inglese" in result.output
-    assert result.exit_code == 0
-
-
 # <lang> tests
[email protected]
 def test_lang_not_valid():
     """Invalid <lang> should display an error"""
     result = runner(['--lang', 'xx', 'test'])
@@ -96,6 +88,7 @@
     assert result.exit_code != 0
 
 
[email protected]
 def test_lang_nocheck():
     """Invalid <lang> (with <nocheck>) should display an error message from 
gtts"""
     with LogCapture() as lc:
@@ -105,12 +98,11 @@
 
     assert 'lang: xx' in log
     assert 'lang_check: False' in log
-    assert "Probable cause: Unsupported language 'xx'" in result.output
+    assert "Unsupported language 'xx'" in result.output
     assert result.exit_code != 0
 
 # Param set tests
-
-
[email protected]
 def test_params_set():
     """Options should set gTTS instance arguments (read from debug log)"""
     with LogCapture() as lc:
@@ -168,6 +160,7 @@
     return '\n'.join([u"%s %s\n  %s" % r for r in lc.actual()])
 
 
[email protected]
 def test_stdin_text():
     with LogCapture() as lc:
         result = runner_debug(['-'], textstdin)
@@ -177,6 +170,7 @@
     assert result.exit_code == 0
 
 
[email protected]
 def test_stdin_text_unicode():
     with LogCapture() as lc:
         result = runner_debug(['-'], textstdin_unicode)
@@ -186,6 +180,7 @@
     assert result.exit_code == 0
 
 
[email protected]
 def test_stdin_file():
     with LogCapture() as lc:
         result = runner_debug(['--file', '-'], textstdin)
@@ -195,6 +190,7 @@
     assert result.exit_code == 0
 
 
[email protected]
 def test_stdin_file_unicode():
     with LogCapture() as lc:
         result = runner_debug(['--file', '-'], textstdin_unicode)
@@ -204,6 +200,7 @@
     assert result.exit_code == 0
 
 
[email protected]
 def test_text():
     with LogCapture() as lc:
         result = runner_debug([text])
@@ -213,6 +210,7 @@
     assert result.exit_code == 0
 
 
[email protected]
 def test_text_unicode():
     with LogCapture() as lc:
         result = runner_debug([text_unicode])
@@ -222,6 +220,7 @@
     assert result.exit_code == 0
 
 
[email protected]
 def test_file_ascii():
     with LogCapture() as lc:
         result = runner_debug(['--file', textfile_ascii])
@@ -231,6 +230,7 @@
     assert result.exit_code == 0
 
 
[email protected]
 def test_file_utf8():
     with LogCapture() as lc:
         result = runner_debug(['--file', textfile_utf8])
@@ -240,14 +240,16 @@
     assert result.exit_code == 0
 
 
[email protected]
 def test_stdout():
     result = runner(['test'])
 
-    # The MP3 encoding (LAME 3.99.5) leaves a signature in the raw output
-    assert 'LAME3.99.5' in result.output
+    # The MP3 encoding (LAME 3.99.5) used to leave a signature in the raw 
output
+    # This no longer appears to be the case
     assert result.exit_code == 0
 
 
[email protected]
 def test_file(tmp_path):
     filename = tmp_path / 'out.mp3'
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/tests/test_lang.py 
new/gTTS-2.2.2/gtts/tests/test_lang.py
--- old/gTTS-2.1.1/gtts/tests/test_lang.py      2020-01-26 04:22:29.000000000 
+0100
+++ new/gTTS-2.2.2/gtts/tests/test_lang.py      2021-02-04 05:09:27.000000000 
+0100
@@ -1,32 +1,22 @@
 # -*- coding: utf-8 -*-
 import pytest
-from gtts.lang import tts_langs, _fetch_langs, _extra_langs
+from gtts.lang import tts_langs, _extra_langs, _fallback_deprecated_lang
+from gtts.langs import _main_langs
 
+"""Test language list"""
 
-"""Test language list downloading"""
 
-
-def test_fetch_langs():
+def test_main_langs():
     """Fetch languages successfully"""
-    # Downloaded Languages
-    # Safe to assume 'en' (english) will always be there
-    scraped_langs = _fetch_langs()
+    # Safe to assume 'en' (English) will always be there
+    scraped_langs = _main_langs()
     assert 'en' in scraped_langs
 
-    # Scraping garbage
-    assert 'Detect language' not in scraped_langs
-    assert '???' not in scraped_langs
-
-    # Add-in Languages
-    all_langs = tts_langs()
-    extra_langs = _extra_langs()
-    assert len(all_langs) == len(scraped_langs) + len(extra_langs)
-
 
-def test_fetch_langs_exception():
-    """Raise RuntimeError on language fetch exception"""
-    with pytest.raises(RuntimeError):
-        tts_langs(tld="invalid")
+def test_deprecated_lang():
+    """Test language deprecation fallback"""
+    with pytest.deprecated_call():
+        assert _fallback_deprecated_lang('en-gb') == 'en'
 
 
 if __name__ == '__main__':
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/tests/test_tts.py 
new/gTTS-2.2.2/gtts/tests/test_tts.py
--- old/gTTS-2.1.1/gtts/tests/test_tts.py       2020-01-26 04:22:29.000000000 
+0100
+++ new/gTTS-2.2.2/gtts/tests/test_tts.py       2021-02-04 05:09:27.000000000 
+0100
@@ -5,11 +5,12 @@
 from six.moves import urllib
 
 from gtts.tts import gTTS, gTTSError
-from gtts.lang import _fetch_langs, _extra_langs
+from gtts.langs import _main_langs
+from gtts.lang import _extra_langs
 
 # Testing all languages takes some time.
 # Set TEST_LANGS envvar to choose languages to test.
-#  * 'fetch': Languages fetched from the Web
+#  * 'main': Languages extracted from the Web
 #  * 'extra': Languagee set in Languages.EXTRA_LANGS
 #  * 'all': All of the above
 #  * <csv>: Languages tags list to test
@@ -26,10 +27,10 @@
 """
 env = os.environ.get('TEST_LANGS')
 if not env or env == 'all':
-    langs = _fetch_langs()
+    langs = _main_langs()
     langs.update(_extra_langs())
-elif env == 'fetch':
-    langs = _fetch_langs()
+elif env == 'main':
+    langs = _main_langs()
 elif env == 'extra':
     langs = _extra_langs()
 else:
@@ -37,6 +38,7 @@
     langs = env_langs
 
 
[email protected]
 @pytest.mark.parametrize('lang', langs.keys(), ids=list(langs.values()))
 def test_TTS(tmp_path, lang):
     """Test all supported languages and file save"""
@@ -46,13 +48,14 @@
     for slow in (False, True):
         filename = tmp_path / 'test_{}_.mp3'.format(lang)
         # Create gTTS and save
-        tts = gTTS(text=text, lang=lang, slow=slow)
+        tts = gTTS(text=text, lang=lang, slow=slow, lang_check=False)
         tts.save(filename)
 
-        # Check if files created is > 2k
-        assert filename.stat().st_size > 2000
+        # Check if files created is > 1.5
+        assert filename.stat().st_size > 1500
 
 
[email protected]
 def test_unsupported_language_check():
     """Raise ValueError on unsupported language (with language check)"""
     lang = 'xx'
@@ -88,6 +91,7 @@
         tts.write_to_fp(5)
 
 
[email protected]
 def test_save(tmp_path):
     """Save .mp3 file successfully"""
     filename = tmp_path / 'save.mp3'
@@ -99,19 +103,14 @@
     assert filename.stat().st_size > 2000
 
 
-def test_get_urls():
-    """Get request URLs list"""
-
-    tts = gTTS(text='test', tld='com', lang='en-uk')
-    urls = tts.get_urls()
-
-    # Check the url
-    r = urllib.parse.urlparse(urls[0])
-    assert r.scheme == 'https'
-    assert r.netloc == 'translate.google.com'
-    assert r.path == '/translate_tts'
-    assert 'test' in urllib.parse.parse_qs(r.query)['q']
-    assert 'en-uk' in urllib.parse.parse_qs(r.query)['tl']
[email protected]
+def test_get_bodies():
+    """get request bodies list"""
+    tts = gTTS(text='test', tld='com', lang='en')
+    body = tts.get_bodies()[0]
+    assert 'test' in body
+    # \"en\" url-encoded
+    assert '%5C%22en%5C%22' in body
 
 
 def test_msg():
@@ -142,11 +141,11 @@
     error403 = gTTSError(tts=tts403, response=response403)
     assert error403.msg == "403 (aaa) from TTS API. Probable cause: Bad token 
or upstream API changes"
 
-    # 404 (and not lang_check)
-    tts404 = Mock(lang='xx', lang_check=False)
-    response404 = Mock(status_code=404, reason='bbb')
-    error404 = gTTSError(tts=tts404, response=response404)
-    assert error404.msg == "404 (bbb) from TTS API. Probable cause: 
Unsupported language 'xx'"
+    # 200 (and not lang_check)
+    tts200 = Mock(lang='xx', lang_check=False)
+    response404 = Mock(status_code=200, reason='bbb')
+    error200 = gTTSError(tts=tts200, response=response404)
+    assert error200.msg == "200 (bbb) from TTS API. Probable cause: No audio 
stream in response. Unsupported language 'xx'"
 
     # >= 500
     tts500 = Mock()
@@ -161,6 +160,7 @@
     assert error100.msg == "100 (ddd) from TTS API. Probable cause: Unknown"
 
 
[email protected]
 def test_WebRequest(tmp_path):
     """Test Web Requests"""
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/tokenizer/core.py 
new/gTTS-2.2.2/gtts/tokenizer/core.py
--- old/gTTS-2.1.1/gtts/tokenizer/core.py       2020-01-26 04:22:29.000000000 
+0100
+++ new/gTTS-2.2.2/gtts/tokenizer/core.py       2021-02-04 05:09:27.000000000 
+0100
@@ -3,7 +3,7 @@
 
 
 class RegexBuilder():
-    """Builds regex using arguments passed into a pattern template.
+    r"""Builds regex using arguments passed into a pattern template.
 
     Builds a regex object for which the pattern is made from an argument
     passed into a template. If more than one argument is passed (iterable),
@@ -71,7 +71,7 @@
 
 
 class PreProcessorRegex():
-    """Regex-based substitution text pre-processor.
+    r"""Regex-based substitution text pre-processor.
 
     Runs a series of regex substitutions (``re.sub``) from each ``regex`` of a
     :class:`gtts.tokenizer.core.RegexBuilder` with an extra ``repl``
@@ -147,7 +147,7 @@
 
 
 class PreProcessorSub():
-    """Simple substitution text preprocessor.
+    r"""Simple substitution text preprocessor.
 
     Performs string-for-string substitution from list a find/replace pairs.
     It abstracts :class:`gtts.tokenizer.core.PreProcessorRegex` with a default
@@ -213,7 +213,7 @@
 
 
 class Tokenizer():
-    """An extensible but simple generic rule-based tokenizer.
+    r"""An extensible but simple generic rule-based tokenizer.
 
     A generic and simple string tokenizer that takes a list of functions
     (called `tokenizer cases`) returning ``regex`` objects and joins them by
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/tts.py new/gTTS-2.2.2/gtts/tts.py
--- old/gTTS-2.1.1/gtts/tts.py  2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/gtts/tts.py  2021-02-04 05:09:27.000000000 +0100
@@ -1,13 +1,20 @@
 # -*- coding: utf-8 -*-
 from gtts.tokenizer import pre_processors, Tokenizer, tokenizer_cases
 from gtts.utils import _minimize, _len, _clean_tokens, _translate_url
-from gtts.lang import tts_langs
+from gtts.lang import tts_langs, _fallback_deprecated_lang
 
-from gtts_token import gtts_token
 from six.moves import urllib
-import urllib3
+try:
+    from urllib.parse import quote
+    import urllib3
+except ImportError:
+    from urllib import quote
+    import urllib2
 import requests
 import logging
+import json
+import re
+import base64
 
 __all__ = ['gTTS', 'gTTSError']
 
@@ -20,10 +27,11 @@
     """Read Speed
 
     The Google TTS Translate API supports two speeds:
-        'slow' <= 0.3 < 'normal'
+        Slow: True
+        Normal: None
     """
-    SLOW = 0.3
-    NORMAL = 1
+    SLOW = True
+    NORMAL = None
 
 
 class gTTS:
@@ -76,7 +84,7 @@
             left to speak after pre-precessing, tokenizing and cleaning.
         ValueError: When ``lang_check`` is ``True`` and ``lang`` is not 
supported.
         RuntimeError: When ``lang_check`` is ``True`` but there's an error 
loading
-            the languages dictionnary.
+            the languages dictionary.
 
     """
 
@@ -86,8 +94,10 @@
         "User-Agent":
             "Mozilla/5.0 (Windows NT 10.0; WOW64) "
             "AppleWebKit/537.36 (KHTML, like Gecko) "
-            "Chrome/47.0.2526.106 Safari/537.36"
+            "Chrome/47.0.2526.106 Safari/537.36",
+        "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
     }
+    GOOGLE_TTS_RPC = "jQ1olc"
 
     def __init__(
             self,
@@ -124,18 +134,21 @@
         self.tld = tld
 
         # Language
-        if lang_check:
+        self.lang_check = lang_check
+        self.lang = lang
+
+        if self.lang_check:
+            # Fallback lang in case it is deprecated
+            self.lang = _fallback_deprecated_lang(lang)
+
             try:
-                langs = tts_langs(self.tld)
-                if lang.lower() not in langs:
-                    raise ValueError("Language not supported: %s" % lang)
+                langs = tts_langs()
+                if self.lang not in langs:
+                   raise ValueError("Language not supported: %s" % lang)
             except RuntimeError as e:
                 log.debug(str(e), exc_info=True)
                 log.warning(str(e))
 
-        self.lang_check = lang_check
-        self.lang = lang.lower()
-
         # Read speed
         if slow:
             self.speed = Speed.SLOW
@@ -146,9 +159,6 @@
         self.pre_processor_funcs = pre_processor_funcs
         self.tokenizer_func = tokenizer_func
 
-        # Google Translate token
-        self.token = gtts_token.Token()
-
     def _tokenize(self, text):
         # Pre-clean
         text = text.strip()
@@ -172,6 +182,10 @@
         min_tokens = []
         for t in tokens:
             min_tokens += _minimize(t, ' ', self.GOOGLE_TTS_MAX_CHARS)
+
+        # Filter empty tokens, post-minimize
+        tokens = [t for t in min_tokens if t]
+
         return min_tokens
 
     def _prepare_requests(self):
@@ -181,39 +195,23 @@
             list: ``requests.PreparedRequests_``. 
<https://2.python-requests.org/en/master/api/#requests.PreparedRequest>`_``.
         """
         # TTS API URL
-        translate_url = _translate_url(tld=self.tld, path="translate_tts")
+        translate_url = _translate_url(tld=self.tld, 
path="_/TranslateWebserverUi/data/batchexecute")
 
         text_parts = self._tokenize(self.text)
+        log.debug("text_parts: %s", str(text_parts))
         log.debug("text_parts: %i", len(text_parts))
         assert text_parts, 'No text to send to TTS API'
 
         prepared_requests = []
         for idx, part in enumerate(text_parts):
-            try:
-                # Calculate token
-                part_tk = self.token.calculate_token(part)
-            except requests.exceptions.RequestException as e:  # pragma: no 
cover
-                log.debug(str(e), exc_info=True)
-                raise gTTSError(
-                    "Connection error during token calculation: %s" %
-                    str(e))
+            data = self._package_rpc(part)
 
-            payload = {'ie': 'UTF-8',
-                       'q': part,
-                       'tl': self.lang,
-                       'ttsspeed': self.speed,
-                       'total': len(text_parts),
-                       'idx': idx,
-                       'client': 'tw-ob',
-                       'textlen': _len(part),
-                       'tk': part_tk}
-
-            log.debug("payload-%i: %s", idx, payload)
+            log.debug("data-%i: %s", idx, data)
 
             # Request
-            r = requests.Request(method='GET',
+            r = requests.Request(method='POST',
                                  url=translate_url,
-                                 params=payload,
+                                 data=data,
                                  headers=self.GOOGLE_TTS_HEADERS)
 
             # Prepare request
@@ -221,17 +219,21 @@
 
         return prepared_requests
 
-    def get_urls(self):
-        """Get TTS API request URL(s) that would be sent to the TTS API.
+    def _package_rpc(self, text):
+        parameter = [text, self.lang, self.speed, "null"]
+        escaped_parameter = json.dumps(parameter, separators=(',', ':'))
+
+        rpc = [[[self.GOOGLE_TTS_RPC, escaped_parameter, None, "generic"]]]
+        espaced_rpc = json.dumps(rpc, separators=(',', ':'))
+        return "f.req={}&".format(quote(espaced_rpc))
 
-        Returns:
-            list: A list of TTS API request URLs to make.
+    def get_bodies(self):
+        """Get TTS API request bodies(s) that would be sent to the TTS API.
 
-                This is particularly useful to get the list of URLs generated
-                by ``gTTS`` but not yet fullfilled,
-                for example to be used by an external program.
+        Returns:
+            list: A list of TTS API request bodiess to make.
         """
-        return [pr.url for pr in self._prepare_requests()]
+        return [pr.body for pr in self._prepare_requests()]
 
     def write_to_fp(self, fp):
         """Do the TTS API request(s) and write bytes to a file-like object.
@@ -246,7 +248,12 @@
         """
         # When disabling ssl verify in requests (for proxies and firewalls),
         # urllib3 prints an insecure warning on stdout. We disable that.
-        urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
+        try:
+            urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
+        except:
+            pass
+ 
+
 
         prepared_requests = self._prepare_requests()
         for idx, pr in enumerate(prepared_requests):
@@ -273,8 +280,18 @@
 
             try:
                 # Write
-                for chunk in r.iter_content(chunk_size=1024):
-                    fp.write(chunk)
+                for line in r.iter_lines(chunk_size=1024):
+                    decoded_line = line.decode('utf-8')
+                    if 'jQ1olc' in decoded_line:
+                        audio_search = re.search(r'jQ1olc","\[\\"(.*)\\"]', 
decoded_line)
+                        if audio_search:
+                            as_bytes = audio_search.group(1).encode('ascii')
+                            decoded = base64.b64decode(as_bytes)
+                            fp.write(decoded)
+                        else:
+                            # Request successful, good response,
+                            # no audio stream in response
+                            raise gTTSError(tts=self, response=r)
                 log.debug("part-%i written to %s", idx, fp)
             except (AttributeError, TypeError) as e:
                 raise TypeError(
@@ -334,8 +351,8 @@
 
             if status == 403:
                 cause = "Bad token or upstream API changes"
-            elif status == 404 and not tts.lang_check:
-                cause = "Unsupported language '%s'" % self.tts.lang
+            elif status == 200 and not tts.lang_check:
+                cause = "No audio stream in response. Unsupported language 
'%s'" % self.tts.lang
             elif status >= 500:
                 cause = "Uptream API error. Try again later."
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/utils.py new/gTTS-2.2.2/gtts/utils.py
--- old/gTTS-2.1.1/gtts/utils.py        2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/gtts/utils.py        2021-02-04 05:09:27.000000000 +0100
@@ -99,4 +99,4 @@
         string: A Google Translate URL `https://translate.google.<tld>/path`
     """
     _GOOGLE_TTS_URL = "https://translate.google.{}/{}";
-    return _GOOGLE_TTS_URL.format(tld, path)
+    return _GOOGLE_TTS_URL.format(tld, path)
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/gtts/version.py 
new/gTTS-2.2.2/gtts/version.py
--- old/gTTS-2.1.1/gtts/version.py      2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/gtts/version.py      2021-02-04 05:09:27.000000000 +0100
@@ -1 +1 @@
-__version__ = '2.1.1'
+__version__ = '2.2.2'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/pyproject.toml 
new/gTTS-2.2.2/pyproject.toml
--- old/gTTS-2.1.1/pyproject.toml       2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/pyproject.toml       2021-02-04 05:09:27.000000000 +0100
@@ -1,7 +1,10 @@
+[build-system]
+requires = ["setuptools", "wheel"]
+
 [tool.towncrier]
 package = "gtts"
 filename = "CHANGELOG.rst"
 directory = "news/"
 underlines = ["-", "~", "_"]
 title_format = "{version} ({project_date})"
-issue_format = "`#{issue} <https://github.com/pndurette/gTTS/issues/{issue}>`_"
\ No newline at end of file
+issue_format = "`#{issue} <https://github.com/pndurette/gTTS/issues/{issue}>`_"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/pytest.ini new/gTTS-2.2.2/pytest.ini
--- old/gTTS-2.1.1/pytest.ini   2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/pytest.ini   2021-02-04 05:09:27.000000000 +0100
@@ -1,2 +1,5 @@
 [pytest]
-minversion = 3.9
\ No newline at end of file
+maxversion = 4.6.11
+
+markers =
+    net: marks tests that call use the net (using the URL endpoint, deselect 
with '-m "not net"')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/setup.cfg new/gTTS-2.2.2/setup.cfg
--- old/gTTS-2.1.1/setup.cfg    2020-01-26 04:22:49.392464600 +0100
+++ new/gTTS-2.2.2/setup.cfg    2021-02-04 05:10:00.684482000 +0100
@@ -20,10 +20,10 @@
        Operating System :: POSIX :: Linux
        Operating System :: Microsoft :: Windows
        Programming Language :: Python :: 2.7
-       Programming Language :: Python :: 3.5
        Programming Language :: Python :: 3.6
        Programming Language :: Python :: 3.7
        Programming Language :: Python :: 3.8
+       Programming Language :: Python :: 3.9
        Topic :: Software Development :: Libraries
        Topic :: Multimedia :: Sound/Audio :: Speech
 license_file = LICENSE
@@ -32,21 +32,16 @@
 
 [options]
 python_requires = >= 2.7
-setup_requires = 
-       setuptools >= 38.6
-       twine >= 1.11
 include_package_data = True
 packages = find:
 install_requires = 
        six
-       beautifulsoup4
        click
        requests
-       gtts_token >= 1.1.3
 
 [options.extras_require]
 tests = 
-       pytest >= 3.9
+       pytest == 4.6.11
        pytest-cov
        flake8
        testfixtures
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gTTS-2.1.1/setup.py new/gTTS-2.2.2/setup.py
--- old/gTTS-2.1.1/setup.py     2020-01-26 04:22:29.000000000 +0100
+++ new/gTTS-2.2.2/setup.py     2021-02-04 05:09:27.000000000 +0100
@@ -1,5 +1,9 @@
 from setuptools import setup
 from codecs import open
+import site
+
+# PEP517
+site.ENABLE_USER_SITE = True
 
 exec(open('gtts/version.py').read())
 

Reply via email to