diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..53bafb7
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+vdmAPI
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..cbf7895
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..c24097c
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vdmAPI.iml b/.idea/vdmAPI.iml
new file mode 100644
index 0000000..d0876a7
--- /dev/null
+++ b/.idea/vdmAPI.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..d2e2502
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,202 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1468084486688
+
+ 1468084486688
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/VDMAPI/Display/__init__.py b/VDMAPI/Display/__init__.py
new file mode 100644
index 0000000..7bcea61
--- /dev/null
+++ b/VDMAPI/Display/__init__.py
@@ -0,0 +1,7 @@
+# import all module include into current package
+__name__ = "VDMAPI"
+__version__ = 1.0
+__author__ = "antoine roux"
+__author_email__= "antoinroux@hotmail.fr"
+__url__ = "antoine-roux.tk"
+__description__ = "an api for recover a list of random vdm from vdm.fr and display it on different GUI (i3, tkinter, windows or commande line"
diff --git a/VDMAPI/Display/__pycache__/__init__.cpython-35.pyc b/VDMAPI/Display/__pycache__/__init__.cpython-35.pyc
new file mode 100644
index 0000000..00b383f
Binary files /dev/null and b/VDMAPI/Display/__pycache__/__init__.cpython-35.pyc differ
diff --git a/VDMAPI/Display/__pycache__/console.cpython-35.pyc b/VDMAPI/Display/__pycache__/console.cpython-35.pyc
new file mode 100644
index 0000000..507f1d0
Binary files /dev/null and b/VDMAPI/Display/__pycache__/console.cpython-35.pyc differ
diff --git a/VDMAPI/Display/__pycache__/i3.cpython-35.pyc b/VDMAPI/Display/__pycache__/i3.cpython-35.pyc
new file mode 100644
index 0000000..012b311
Binary files /dev/null and b/VDMAPI/Display/__pycache__/i3.cpython-35.pyc differ
diff --git a/VDMAPI/Display/__pycache__/tkinter.cpython-35.pyc b/VDMAPI/Display/__pycache__/tkinter.cpython-35.pyc
new file mode 100644
index 0000000..94b0ee7
Binary files /dev/null and b/VDMAPI/Display/__pycache__/tkinter.cpython-35.pyc differ
diff --git a/VDMAPI/Display/console.py b/VDMAPI/Display/console.py
new file mode 100644
index 0000000..7317811
--- /dev/null
+++ b/VDMAPI/Display/console.py
@@ -0,0 +1,12 @@
+from ..VDM import VDM
+
+class console(object):
+ """display all vdm into console"""
+ def __init__(self):
+ super(console, self).__init__()
+ self.v = VDM()
+
+ def render(self):
+ lstAllVDM = self.v.get()
+ for i, vdm in enumerate(lstAllVDM):
+ print(str(i)+" : "+vdm)
diff --git a/VDMAPI/Display/i3.py b/VDMAPI/Display/i3.py
new file mode 100644
index 0000000..9fb48b3
--- /dev/null
+++ b/VDMAPI/Display/i3.py
@@ -0,0 +1,20 @@
+from ..VDM import VDM
+import subprocess
+import i3
+
+class i3(object):
+ """display all vdm into i3 menu"""
+ def __init__(self):
+ super(i3, self).__init__()
+ self.v = VDM()
+
+ def render(self):
+ lstAllVDM = self.v.get()
+
+ dmenu = subprocess.Popen(['/usr/bin/dmenu', '-i','-l', str(len(lstAllVDM))],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE)
+
+ menu_str = '\n'.join(lstAllVDM)
+ win_str = dmenu.communicate(menu_str.encode('utf-8'))[0].decode('utf-8').rstrip()
+ print(win_str)
\ No newline at end of file
diff --git a/VDMAPI/Display/tkinter.py b/VDMAPI/Display/tkinter.py
new file mode 100644
index 0000000..3de8644
--- /dev/null
+++ b/VDMAPI/Display/tkinter.py
@@ -0,0 +1,18 @@
+from ..VDM import VDM
+
+import tkinter as tk
+import pygubu
+import VDMAPI
+import os
+
+class tkinter:
+ def __init__(self):
+ self.root = tk.Tk()
+
+ builder = builder = pygubu.Builder()
+ uiPath = os.path.join(VDMAPI.__path__[0], './', 'tkinter.ui')
+ builder.add_from_file(uiPath)
+ mainwindow = builder.get_object('frame', self.root)
+
+ def render(self):
+ self.root.mainloop()
\ No newline at end of file
diff --git a/VDMAPI/Display/windows.py b/VDMAPI/Display/windows.py
new file mode 100644
index 0000000..8974669
--- /dev/null
+++ b/VDMAPI/Display/windows.py
@@ -0,0 +1,12 @@
+from ..VDM import VDM
+
+class windows(object):
+ """display all vdm into windows os"""
+ def __init__(self):
+ super(windows, self).__init__()
+ v = VDM()
+
+ def render(self):
+ lstAllVDM = self.v.get()
+ for i, vdm in enumerate(lstAllVDM):
+ print(str(i)+" : "+vdm)
\ No newline at end of file
diff --git a/VDMAPI/HtmlParser.py b/VDMAPI/HtmlParser.py
new file mode 100644
index 0000000..c03a52d
--- /dev/null
+++ b/VDMAPI/HtmlParser.py
@@ -0,0 +1,26 @@
+from html.parser import HTMLParser
+from html.entities import name2codepoint
+
+class MyHTMLParser(HTMLParser):
+ def __init__(self):
+ super(MyHTMLParser, self).__init__()
+ self.vdm = []
+ self.save = False
+
+ def _searchClass(self, listTuple, className="post article"):
+ for v in listTuple:
+ if v[0] == 'class' and v[1] == className:
+ return True
+ return False
+
+ def handle_starttag(self, tag, attrs):
+ if tag == "p" and self._searchClass(attrs, className="content"):
+ self.save = True
+
+ def handle_data(self, data):
+ if self.save:
+ self.vdm.append(data)
+ self.save = False
+
+ def getText(self):
+ return self.vdm
\ No newline at end of file
diff --git a/VDMAPI/VDM.py b/VDMAPI/VDM.py
new file mode 100644
index 0000000..c2f773a
--- /dev/null
+++ b/VDMAPI/VDM.py
@@ -0,0 +1,30 @@
+from .HtmlParser import MyHTMLParser
+import requests
+
+class VDM(object):
+ """VDM module for recover random VDM"""
+
+ def __init__(self):
+ self.url = "http://www.viedemerde.fr/aleatoire"
+ self.vdm = {}
+
+ def get(self):
+ try:
+ r = requests.get(self.url)
+ r.encoding = 'utf-8' # ISO-8859-1
+
+ if(r.status_code == requests.codes.ok):
+ parser = MyHTMLParser()
+ parser.feed(r.text)
+ self.vdm = parser.getText()
+
+ print("Sucess {}".format(r.status_code))
+
+ return self.vdm
+ else:
+ print("Error {}".format(r.status_code))
+
+ except ConnectionError as e:
+ print("Connection error {}".format(e))
+
+
\ No newline at end of file
diff --git a/VDMAPI/__init__.py b/VDMAPI/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/VDMAPI/__pycache__/Display.cpython-35.pyc b/VDMAPI/__pycache__/Display.cpython-35.pyc
new file mode 100644
index 0000000..938d8ef
Binary files /dev/null and b/VDMAPI/__pycache__/Display.cpython-35.pyc differ
diff --git a/VDMAPI/__pycache__/HtmlParser.cpython-35.pyc b/VDMAPI/__pycache__/HtmlParser.cpython-35.pyc
new file mode 100644
index 0000000..72d6dca
Binary files /dev/null and b/VDMAPI/__pycache__/HtmlParser.cpython-35.pyc differ
diff --git a/VDMAPI/__pycache__/VDM.cpython-35.pyc b/VDMAPI/__pycache__/VDM.cpython-35.pyc
new file mode 100644
index 0000000..924f701
Binary files /dev/null and b/VDMAPI/__pycache__/VDM.cpython-35.pyc differ
diff --git a/VDMAPI/__pycache__/__init__.cpython-35.pyc b/VDMAPI/__pycache__/__init__.cpython-35.pyc
new file mode 100644
index 0000000..c4677f2
Binary files /dev/null and b/VDMAPI/__pycache__/__init__.cpython-35.pyc differ
diff --git a/VDMAPI/__pycache__/htmlparser.cpython-35.pyc b/VDMAPI/__pycache__/htmlparser.cpython-35.pyc
new file mode 100644
index 0000000..b1b7a5e
Binary files /dev/null and b/VDMAPI/__pycache__/htmlparser.cpython-35.pyc differ
diff --git a/VDMAPI/tkinter.ui b/VDMAPI/tkinter.ui
new file mode 100644
index 0000000..e12150f
--- /dev/null
+++ b/VDMAPI/tkinter.ui
@@ -0,0 +1,46 @@
+
+
+
+
diff --git a/main.py b/main.py
new file mode 100755
index 0000000..c31834f
--- /dev/null
+++ b/main.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+import sys
+
+if __name__ == "__main__":
+ from VDMAPI.Display.console import console as display
+
+ if "-d" in sys.argv:
+ index = next(i for i, c in enumerate(sys.argv) if c == "-d")
+
+ if len(sys.argv) > index+1:
+ displayType = sys.argv[index+1]
+ if displayType == "i3":
+ from VDMAPI.Display.i3 import i3 as display
+
+ elif displayType == "tkinter":
+ from VDMAPI.Display.tkinter import tkinter as display
+
+ elif displayType == "windows":
+ from VDMAPI.Display.windows import windows as display
+
+ elif displayType == "console":
+ None
+
+ else:
+ print("Error bad display mode accepted value are : i3, tkinter, windows of console")
+ else:
+ print("Error too few argument -d need value : i3, tkinter, windows of console")
+
+ d = display()
+ d.render()