<!doctype html>
<html>
  <!--
  Hello, This is Muhammet, I am a product oriented from-scratch
  web-developer. It's my hobby to think about new ideas and
  implement prototypes.

  Some of the things I like: Python (Django/Flask),
  Linux, Emacs, Restful Services, Data Science (R/Python),
  Html, SASS, Javascript (React/Jquery) and Sketch.

  PS. Yes you are reading the source markup of the page you are
  looking at. If you want to learn the details look at the repo
  @ https://github.com/jeffisabelle/my-blog-engine-2
  -->
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- higlight.js styles -->
    <link href="/static/css/highlight/solarized-dark.css" rel="stylesheet"/>
    <!-- fonts -->
    <link href='https://fonts.googleapis.com/css?family=Actor|Advent+Pro:400,300,500,600,700' rel='stylesheet' type='text/css'>
    <!-- font-awesome -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
    <!-- animate.css -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.4.0/animate.min.css">
    <!-- main -->
    <link href="/static/css/main.css" rel="stylesheet"/>
    <title>Muhammet Can :: Subtitle Problems on Ubuntu Linux</title>
  </head>
  <body>
    <div id="left-container">
      <pre><code></code></pre>
    </div>
      
    <div id="profile">
      <div class="container-fluid">
        <div class="row">
          <div class="col-xs-12">

            <div class="avatar">
              <del>my awesome picture</del>
              <img alt="" src="/static/img/thuglife.png"/>
            </div>
            <div class="nav">
              <ul>
                <a href="/">
                  <li>home</li>
                </a>
                <a href="#"> <!-- implement later -->
                  <li>projects</li>
                </a>
                <a href="#"> <!-- implement later -->
                  <li>about</li>
                </a>
              </ul>
            </div>
            <div class="social">
              <a href="https://tr.linkedin.com/in/muhammetcan" target="_blank">
                <i class="fa fa-linkedin-square l"><del>linkedin</del></i>
              </a>
              <a href="https://github.com/jeffisabelle" target="_blank">
                <i class="fa fa-github-square l"><del>github</del></i>
              </a>
              <a href="https://twitter.com/jeffisabelle" target="_blank">
                <i class="fa fa-twitter-square l"><del>twitter</del></i>
              </a>
            </div>
          </div> <!-- /profile -->
        </div> <!-- /col-xs-12 -->
      </div> <!-- /row -->
    </div> <!-- /container -->
  
    <div id="right-container">
      <article class="animated fadeInRight">
        <!-- dont put the source of actual blog here.
        ugly markup makes it hard to follow. -->
      </article>

      <div class="container">
        <div id="disqus_thread"></div>
        <noscript>Please enable JavaScript to view the
          <a href="http://disqus.com/?ref_noscript">
            comments powered by Disqus.</a></noscript>

        <a href="http://disqus.com" class="dsq-brlink">comments
          powered by <span class="logo-disqus">Disqus</span></a>
      </div>
    </div> <!-- /right-container -->
  </body>

  <!-- jquery -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-alpha1/jquery.min.js"></script>
  <!-- highlight.js -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.0.0/highlight.min.js"></script>
  <!-- bootstrap.js -->
  <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha/js/bootstrap.min.js"></script>
  <!-- main.js -->
  <script src="/static/js/main.js"></script>
</html>

Subtitle Problems on Ubuntu Linux

If you are running a linux distro and you need subtitles when watching series/movies, it’s more than likely that you have trouble with subtitles when it comes to non-english characters. The problem comes from character encoding, they usually encoded for windows codesets instead of utf-8 or similar.

So, if your media player can't render your native language specific characters, you probably open the text file with windows character set from your text editor (gedit, kedit, etc.) end you save as the document with utf-8 encoding. That simply solves the problem, but it's kinda headache especially when you are watching 20min sitcoms or something like that, you have to open the editor and change the character set for every single episode.

Instead, I did code a nautilus script that takes a folder and change any files encoding inside that folder. In my case, It is changing windows-1254 character encodes (turkish) to utf-8. I think it is a problem for any language that has special characters. You can find the correct encoding set depending on your language from this wikipedia article and then just change the relevant line from the source code.

http://en.wikipedia.org/wiki/Character_encoding By default, nautilus scripts are placed in /home/.gnome2/nautilus-scripts folder. And you call that scripts by right clicking any folder or file and expanding the Scripts item.

  
#!/usr/bin/python

import os
import codecs

selected = os.environ.get('NAUTILUS_SCRIPT_SELECTED_FILE_PATHS', '')

def convert_line_ending(filename):        
    old = codecs.open(filename, encoding='windows-1254', mode='r')
    newname = "utf-"+filename    
    new = codecs.open(newname, encoding='utf-8',mode='w+')

    for line in old:
        new.write(line)

if selected:
    target = selected.splitlines()[0]
    listing = os.listdir(target)    

    os.chdir(target)

    for file in listing:
        if not file.startswith("utf-"):
            if file.endswith(".srt"):
                try:
                    convert_line_ending(file)
                except:
                    pass       
  

after you put these script into /home/.gnome2/nautilus-scripts/scriptname make it executable. (yes this is mandatory)

    
chmod +x scriptname
    

then you are good to go.

ubuntu-subtitle-problem

more on nautilus scripting;
http://www.ibm.com/developerworks/linux/library/l-script-linux-desktop-2/index.html

some useful nautilus scripts;
http://www.techdrivein.com/2010/09/6-useful-nautilus-extensions-and.html

comments powered by Disqus